mirror of
https://github.com/kamilwylegala/cakephp2-php8.git
synced 2024-11-15 03:18:26 +00:00
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:
parent
75716f76bc
commit
a95654de88
2 changed files with 3 additions and 31 deletions
|
@ -234,8 +234,8 @@ class CakeTestCaseTest extends CakeTestCase {
|
||||||
$manager = $this->getMock('CakeFixtureManager');
|
$manager = $this->getMock('CakeFixtureManager');
|
||||||
$manager->fixturize($test);
|
$manager->fixturize($test);
|
||||||
$test->fixtureManager = $manager;
|
$test->fixtureManager = $manager;
|
||||||
$manager->expects($this->once())->method('load');
|
$manager->expects($this->never())->method('load');
|
||||||
$manager->expects($this->once())->method('unload');
|
$manager->expects($this->never())->method('unload');
|
||||||
$result = $test->run();
|
$result = $test->run();
|
||||||
$this->assertEquals(0, $result->errorCount());
|
$this->assertEquals(0, $result->errorCount());
|
||||||
$this->assertTrue($result->wasSuccessful());
|
$this->assertTrue($result->wasSuccessful());
|
||||||
|
@ -269,6 +269,7 @@ class CakeTestCaseTest extends CakeTestCase {
|
||||||
$manager = $this->getMock('CakeFixtureManager');
|
$manager = $this->getMock('CakeFixtureManager');
|
||||||
$manager->fixturize($test);
|
$manager->fixturize($test);
|
||||||
$test->fixtureManager = $manager;
|
$test->fixtureManager = $manager;
|
||||||
|
$manager->expects($this->never())->method('unload');
|
||||||
$manager->expects($this->once())->method('loadSingle');
|
$manager->expects($this->once())->method('loadSingle');
|
||||||
$result = $test->run();
|
$result = $test->run();
|
||||||
$this->assertEquals(0, $result->errorCount());
|
$this->assertEquals(0, $result->errorCount());
|
||||||
|
@ -285,7 +286,6 @@ class CakeTestCaseTest extends CakeTestCase {
|
||||||
$manager = $this->getMock('CakeFixtureManager');
|
$manager = $this->getMock('CakeFixtureManager');
|
||||||
$manager->fixturize($test);
|
$manager->fixturize($test);
|
||||||
$test->fixtureManager = $manager;
|
$test->fixtureManager = $manager;
|
||||||
$manager->expects($this->once())->method('unload');
|
|
||||||
$result = $test->run();
|
$result = $test->run();
|
||||||
$this->assertEquals(1, $result->errorCount());
|
$this->assertEquals(1, $result->errorCount());
|
||||||
}
|
}
|
||||||
|
|
|
@ -66,34 +66,6 @@ abstract class CakeTestCase extends \PHPUnit\Framework\TestCase {
|
||||||
*/
|
*/
|
||||||
protected $_pathRestore = array();
|
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.)
|
* Called when a test case method is about to start (to be overridden when needed.)
|
||||||
*
|
*
|
||||||
|
|
Loading…
Reference in a new issue