File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -38,26 +38,27 @@ protected function setUp(): void
3838 }
3939
4040 /**
41- * Clean up global state after each test.
41+ * Clean up the App container after each test.
4242 *
4343 * @return void
4444 */
4545 protected function tearDown (): void
4646 {
47- unset( $ GLOBALS [ ' tf ' ] );
47+ \ MyAdmin \App:: resetContainer ( );
4848 parent ::tearDown ();
4949 }
5050
5151 /**
52- * Install a minimal $GLOBALS['tf'] stub so that get_service_define()
53- * can be called without hitting a real database. The stub always
54- * returns -9999, which will never match a real service type.
52+ * Install a minimal tf-like stub via the App container so
53+ * MyAdmin\App::tf()->get_service_define() can be called without hitting
54+ * a real database. The stub always returns -9999, which will never match
55+ * a real service type.
5556 *
5657 * @return void
5758 */
5859 private function setUpGlobalTfStub (): void
5960 {
60- $ GLOBALS [ ' tf ' ] = new class {
61+ $ stub = new class {
6162 /**
6263 * @param string $name
6364 * @return int
@@ -67,6 +68,11 @@ public function get_service_define(string $name): int
6768 return -9999 ;
6869 }
6970 };
71+ \MyAdmin \App::setContainer (
72+ \MyAdmin \App \Testing \TestContainerBuilder::make ()
73+ ->withTf ($ stub )
74+ ->build ()
75+ );
7076 }
7177
7278 // ------------------------------------------------------------------
You can’t perform that action at this time.
0 commit comments