clean: Stop overriding TestCase::run().

Overriding the run method to perform fixture management processing is no longer necessary since moved it to CakeFixtureInjector.

Co-authored-by: Kenshin Okinaka <okinakak@yahoo.co.jp>
This commit is contained in:
Koji Tanaka 2022-12-28 16:24:34 +09:00 committed by Kamil Wylegala
parent 75716f76bc
commit a95654de88
2 changed files with 3 additions and 31 deletions

View file

@ -234,8 +234,8 @@ class CakeTestCaseTest extends CakeTestCase {
$manager = $this->getMock('CakeFixtureManager');
$manager->fixturize($test);
$test->fixtureManager = $manager;
$manager->expects($this->once())->method('load');
$manager->expects($this->once())->method('unload');
$manager->expects($this->never())->method('load');
$manager->expects($this->never())->method('unload');
$result = $test->run();
$this->assertEquals(0, $result->errorCount());
$this->assertTrue($result->wasSuccessful());
@ -269,6 +269,7 @@ class CakeTestCaseTest extends CakeTestCase {
$manager = $this->getMock('CakeFixtureManager');
$manager->fixturize($test);
$test->fixtureManager = $manager;
$manager->expects($this->never())->method('unload');
$manager->expects($this->once())->method('loadSingle');
$result = $test->run();
$this->assertEquals(0, $result->errorCount());
@ -285,7 +286,6 @@ class CakeTestCaseTest extends CakeTestCase {
$manager = $this->getMock('CakeFixtureManager');
$manager->fixturize($test);
$test->fixtureManager = $manager;
$manager->expects($this->once())->method('unload');
$result = $test->run();
$this->assertEquals(1, $result->errorCount());
}

View file

@ -66,34 +66,6 @@ abstract class CakeTestCase extends \PHPUnit\Framework\TestCase {
*/
protected $_pathRestore = array();
/**
* Runs the test case and collects the results in a TestResult object.
* If no TestResult object is passed a new one will be created.
* This method is run for each test method in this class
*
* @param PHPUnit_Framework_TestResult $result The test result object
* @return PHPUnit_Framework_TestResult
* @throws InvalidArgumentException
*/
public function run(PHPUnit_Framework_TestResult $result = null) {
$level = ob_get_level();
if (!empty($this->fixtureManager)) {
$this->fixtureManager->load($this);
}
$result = parent::run($result);
if (!empty($this->fixtureManager)) {
$this->fixtureManager->unload($this);
unset($this->fixtureManager, $this->db);
}
for ($i = ob_get_level(); $i < $level; ++$i) {
ob_start();
}
return $result;
}
/**
* Called when a test case method is about to start (to be overridden when needed.)
*