From bd633c023a55c27e297a74ad9c3fd81376a470d1 Mon Sep 17 00:00:00 2001 From: Koji Tanaka Date: Wed, 28 Dec 2022 15:28:05 +0900 Subject: [PATCH] feat: Implement a fixture callback class using the PHPUnit TestListener interface. --- .../TestSuite/Fixture/CakeFixtureInjector.php | 67 +++++++++++++++++++ phpunit.xml.dist | 3 + 2 files changed, 70 insertions(+) create mode 100644 lib/Cake/TestSuite/Fixture/CakeFixtureInjector.php diff --git a/lib/Cake/TestSuite/Fixture/CakeFixtureInjector.php b/lib/Cake/TestSuite/Fixture/CakeFixtureInjector.php new file mode 100644 index 000000000..60532f786 --- /dev/null +++ b/lib/Cake/TestSuite/Fixture/CakeFixtureInjector.php @@ -0,0 +1,67 @@ +_fixtureManager = $manager ?? new CakeFixtureManager(); + $this->_fixtureManager->shutDown(); + } + + public function startTestSuite(TestSuite $suite) : void { + if (empty($this->_first)) { + $this->_first = $suite; + } + } + + public function endTestSuite(TestSuite $suite) : void { + if ($this->_first === $suite) { + $this->_fixtureManager->shutDown(); + } + } + + public function startTest(Test $test) : void { + $test->fixtureManager = $this->_fixtureManager; + if ($test instanceof CakeTestCase) { + $this->_fixtureManager->fixturize($test); + $this->_fixtureManager->load($test); + } + } + + public function endTest(Test $test, $time) : void { + if ($test instanceof CakeTestCase) { + $this->_fixtureManager->unload($test); + } + } + + public function addError(Test $test, Throwable $e, $time) : void { + } + + public function addFailure(Test $test, AssertionFailedError $e, $time) : void { + } + + public function addIncompleteTest(Test $test, Throwable $e, $time) : void { + } + + public function addSkippedTest(Test $test, Throwable $e, $time) : void { + } + + public function addRiskyTest(Test $test, Throwable $e, $time) : void { + } + + public function addWarning(Test $test, Warning $e, float $time) : void { + } +} diff --git a/phpunit.xml.dist b/phpunit.xml.dist index d5f275641..305949eaa 100644 --- a/phpunit.xml.dist +++ b/phpunit.xml.dist @@ -7,4 +7,7 @@ + + +