mirror of
https://github.com/kamilwylegala/cakephp2-php8.git
synced 2025-02-07 12:36:25 +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');
|
$test = new FixturizedTestCase('testFixturePresent');
|
||||||
$manager = $this->getMock('CakeFixtureManager');
|
$manager = $this->getMock('CakeFixtureManager');
|
||||||
$manager->fixturize($test);
|
$manager->fixturize($test);
|
||||||
$test->sharedFixture = $manager;
|
$test->fixtureManager = $manager;
|
||||||
$manager->expects($this->once())->method('load');
|
$manager->expects($this->once())->method('load');
|
||||||
$manager->expects($this->once())->method('unload');
|
$manager->expects($this->once())->method('unload');
|
||||||
$result = $test->run();
|
$result = $test->run();
|
||||||
|
@ -143,7 +143,7 @@ class CakeTestCaseTest extends CakeTestCase {
|
||||||
$test->autoFixtures = false;
|
$test->autoFixtures = false;
|
||||||
$manager = $this->getMock('CakeFixtureManager');
|
$manager = $this->getMock('CakeFixtureManager');
|
||||||
$manager->fixturize($test);
|
$manager->fixturize($test);
|
||||||
$test->sharedFixture = $manager;
|
$test->fixtureManager = $manager;
|
||||||
$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());
|
||||||
|
@ -160,7 +160,7 @@ class CakeTestCaseTest extends CakeTestCase {
|
||||||
$test->autoFixtures = false;
|
$test->autoFixtures = false;
|
||||||
$manager = $this->getMock('CakeFixtureManager');
|
$manager = $this->getMock('CakeFixtureManager');
|
||||||
$manager->fixturize($test);
|
$manager->fixturize($test);
|
||||||
$test->sharedFixture = $manager;
|
$test->fixtureManager = $manager;
|
||||||
$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());
|
||||||
|
@ -177,7 +177,7 @@ class CakeTestCaseTest extends CakeTestCase {
|
||||||
$test->autoFixtures = false;
|
$test->autoFixtures = false;
|
||||||
$manager = $this->getMock('CakeFixtureManager');
|
$manager = $this->getMock('CakeFixtureManager');
|
||||||
$manager->fixturize($test);
|
$manager->fixturize($test);
|
||||||
$test->sharedFixture = $manager;
|
$test->fixtureManager = $manager;
|
||||||
$manager->expects($this->once())->method('unload');
|
$manager->expects($this->once())->method('unload');
|
||||||
$result = $test->run();
|
$result = $test->run();
|
||||||
$this->assertEquals(1, $result->errorCount());
|
$this->assertEquals(1, $result->errorCount());
|
||||||
|
|
|
@ -468,7 +468,7 @@ HTML;
|
||||||
*/
|
*/
|
||||||
function testFormatColumns() {
|
function testFormatColumns() {
|
||||||
$this->autoFixtures = true;
|
$this->autoFixtures = true;
|
||||||
$this->sharedFixture->load($this);
|
$this->fixtureManager->load($this);
|
||||||
$this->loadFixtures('DataTest', 'Article');
|
$this->loadFixtures('DataTest', 'Article');
|
||||||
|
|
||||||
$this->DataTest =& new SanitizeDataTest(array('alias' => 'DataTest'));
|
$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
|
* @return void
|
||||||
*/
|
*/
|
||||||
public function testFixturePresent() {
|
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 {
|
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.
|
* By default, all fixtures attached to this class will be truncated and reloaded after each test.
|
||||||
* Set this to false to handle manually
|
* Set this to false to handle manually
|
||||||
|
@ -77,12 +85,12 @@ class CakeTestCase extends PHPUnit_Framework_TestCase {
|
||||||
* @throws InvalidArgumentException
|
* @throws InvalidArgumentException
|
||||||
*/
|
*/
|
||||||
public function run(PHPUnit_Framework_TestResult $result = NULL) {
|
public function run(PHPUnit_Framework_TestResult $result = NULL) {
|
||||||
if (!empty($this->sharedFixture)) {
|
if (!empty($this->fixtureManager)) {
|
||||||
$this->sharedFixture->load($this);
|
$this->fixtureManager->load($this);
|
||||||
}
|
}
|
||||||
$result = parent::run($result);
|
$result = parent::run($result);
|
||||||
if (!empty($this->sharedFixture)) {
|
if (!empty($this->fixtureManager)) {
|
||||||
$this->sharedFixture->unload($this);
|
$this->fixtureManager->unload($this);
|
||||||
}
|
}
|
||||||
return $result;
|
return $result;
|
||||||
}
|
}
|
||||||
|
@ -178,12 +186,12 @@ class CakeTestCase extends PHPUnit_Framework_TestCase {
|
||||||
* @see CakeTestCase::$autoFixtures
|
* @see CakeTestCase::$autoFixtures
|
||||||
*/
|
*/
|
||||||
function loadFixtures() {
|
function loadFixtures() {
|
||||||
if (empty($this->sharedFixture)) {
|
if (empty($this->fixtureManager)) {
|
||||||
throw new Exception(__('No fixture manager to load the test fixture'));
|
throw new Exception(__('No fixture manager to load the test fixture'));
|
||||||
}
|
}
|
||||||
$args = func_get_args();
|
$args = func_get_args();
|
||||||
foreach ($args as $class) {
|
foreach ($args as $class) {
|
||||||
$this->sharedFixture->loadSingle($class);
|
$this->fixtureManager->loadSingle($class);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -87,8 +87,8 @@ class CakeTestSuite extends PHPUnit_Framework_TestSuite {
|
||||||
$classes = array();
|
$classes = array();
|
||||||
foreach ($this->getIterator() as $test) {
|
foreach ($this->getIterator() as $test) {
|
||||||
$this->_fixtureManager->fixturize($test);
|
$this->_fixtureManager->fixturize($test);
|
||||||
|
$test->fixtureManager = $this->_fixtureManager;
|
||||||
}
|
}
|
||||||
$this->sharedFixture = $this->_fixtureManager;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
Loading…
Add table
Reference in a new issue