mirror of
https://github.com/kamilwylegala/cakephp2-php8.git
synced 2025-01-31 09:06:17 +00:00
Replacing the use of removed "sharedFixture" and adding custom "fixtureManager" property to CakeTestCase
This commit is contained in:
parent
0eaf437fe4
commit
c3ccf15546
5 changed files with 21 additions and 13 deletions
|
@ -123,7 +123,7 @@ class CakeTestCaseTest extends CakeTestCase {
|
|||
$test = new FixturizedTestCase('testFixturePresent');
|
||||
$manager = $this->getMock('CakeFixtureManager');
|
||||
$manager->fixturize($test);
|
||||
$test->sharedFixture = $manager;
|
||||
$test->fixtureManager = $manager;
|
||||
$manager->expects($this->once())->method('load');
|
||||
$manager->expects($this->once())->method('unload');
|
||||
$result = $test->run();
|
||||
|
@ -143,7 +143,7 @@ class CakeTestCaseTest extends CakeTestCase {
|
|||
$test->autoFixtures = false;
|
||||
$manager = $this->getMock('CakeFixtureManager');
|
||||
$manager->fixturize($test);
|
||||
$test->sharedFixture = $manager;
|
||||
$test->fixtureManager = $manager;
|
||||
$manager->expects($this->once())->method('loadSingle');
|
||||
$result = $test->run();
|
||||
$this->assertEquals(0, $result->errorCount());
|
||||
|
@ -160,7 +160,7 @@ class CakeTestCaseTest extends CakeTestCase {
|
|||
$test->autoFixtures = false;
|
||||
$manager = $this->getMock('CakeFixtureManager');
|
||||
$manager->fixturize($test);
|
||||
$test->sharedFixture = $manager;
|
||||
$test->fixtureManager = $manager;
|
||||
$manager->expects($this->once())->method('loadSingle');
|
||||
$result = $test->run();
|
||||
$this->assertEquals(0, $result->errorCount());
|
||||
|
@ -177,7 +177,7 @@ class CakeTestCaseTest extends CakeTestCase {
|
|||
$test->autoFixtures = false;
|
||||
$manager = $this->getMock('CakeFixtureManager');
|
||||
$manager->fixturize($test);
|
||||
$test->sharedFixture = $manager;
|
||||
$test->fixtureManager = $manager;
|
||||
$manager->expects($this->once())->method('unload');
|
||||
$result = $test->run();
|
||||
$this->assertEquals(1, $result->errorCount());
|
||||
|
|
|
@ -468,7 +468,7 @@ HTML;
|
|||
*/
|
||||
function testFormatColumns() {
|
||||
$this->autoFixtures = true;
|
||||
$this->sharedFixture->load($this);
|
||||
$this->fixtureManager->load($this);
|
||||
$this->loadFixtures('DataTest', 'Article');
|
||||
|
||||
$this->DataTest =& new SanitizeDataTest(array('alias' => 'DataTest'));
|
||||
|
|
2
cake/tests/fixtures/fixturized_test_case.php
vendored
2
cake/tests/fixtures/fixturized_test_case.php
vendored
|
@ -22,7 +22,7 @@ class FixturizedTestCase extends CakeTestCase {
|
|||
* @return void
|
||||
*/
|
||||
public function testFixturePresent() {
|
||||
$this->assertType('CakeFixtureManager', $this->sharedFixture);
|
||||
$this->assertType('CakeFixtureManager', $this->fixtureManager);
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
@ -32,6 +32,14 @@ require_once CAKE_TESTS_LIB . 'cake_test_fixture.php';
|
|||
*/
|
||||
class CakeTestCase extends PHPUnit_Framework_TestCase {
|
||||
|
||||
/**
|
||||
* The class responsible for managinf the creation, loading and removing of fixtures
|
||||
*
|
||||
* @var CakeFixtureManager
|
||||
* @access public
|
||||
*/
|
||||
public $fixtureManager = null;
|
||||
|
||||
/**
|
||||
* By default, all fixtures attached to this class will be truncated and reloaded after each test.
|
||||
* Set this to false to handle manually
|
||||
|
@ -77,12 +85,12 @@ class CakeTestCase extends PHPUnit_Framework_TestCase {
|
|||
* @throws InvalidArgumentException
|
||||
*/
|
||||
public function run(PHPUnit_Framework_TestResult $result = NULL) {
|
||||
if (!empty($this->sharedFixture)) {
|
||||
$this->sharedFixture->load($this);
|
||||
if (!empty($this->fixtureManager)) {
|
||||
$this->fixtureManager->load($this);
|
||||
}
|
||||
$result = parent::run($result);
|
||||
if (!empty($this->sharedFixture)) {
|
||||
$this->sharedFixture->unload($this);
|
||||
if (!empty($this->fixtureManager)) {
|
||||
$this->fixtureManager->unload($this);
|
||||
}
|
||||
return $result;
|
||||
}
|
||||
|
@ -178,12 +186,12 @@ class CakeTestCase extends PHPUnit_Framework_TestCase {
|
|||
* @see CakeTestCase::$autoFixtures
|
||||
*/
|
||||
function loadFixtures() {
|
||||
if (empty($this->sharedFixture)) {
|
||||
if (empty($this->fixtureManager)) {
|
||||
throw new Exception(__('No fixture manager to load the test fixture'));
|
||||
}
|
||||
$args = func_get_args();
|
||||
foreach ($args as $class) {
|
||||
$this->sharedFixture->loadSingle($class);
|
||||
$this->fixtureManager->loadSingle($class);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -87,8 +87,8 @@ class CakeTestSuite extends PHPUnit_Framework_TestSuite {
|
|||
$classes = array();
|
||||
foreach ($this->getIterator() as $test) {
|
||||
$this->_fixtureManager->fixturize($test);
|
||||
$test->fixtureManager = $this->_fixtureManager;
|
||||
}
|
||||
$this->sharedFixture = $this->_fixtureManager;
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
Loading…
Add table
Reference in a new issue