Skip to content

Commit

Permalink
Fixing and testing for CakeTestCase::loadFixtures()
Browse files Browse the repository at this point in the history
  • Loading branch information
lorenzo committed May 8, 2010
1 parent 2b5cd26 commit 4d3a6e8
Show file tree
Hide file tree
Showing 3 changed files with 23 additions and 7 deletions.
17 changes: 17 additions & 0 deletions cake/tests/cases/libs/cake_test_case.test.php
Expand Up @@ -130,6 +130,23 @@ function testLoadFixtures() {
$this->assertEquals(0, $result->failureCount());
}

/**
* testLoadFixturesOnDemand
*
* @access public
* @return void
*/
function testLoadFixturesOnDemand() {
$test = new FixturizedTestCase('testFixtureLoadOnDemand');
$test->autoFixtures = false;
$manager = $this->getMock('CakeFixtureManager');
$manager->fixturize($test);
$test->sharedFixture = $manager;
$manager->expects($this->once())->method('loadSingle');
$result = $test->run();
$this->assertEquals(0, $result->errorCount());
}

/**
* testSkipIf
*
Expand Down
9 changes: 5 additions & 4 deletions cake/tests/fixtures/fixturized_test_case.php
Expand Up @@ -6,13 +6,14 @@
* @subpackage cake.tests.fixtures
*/
class FixturizedTestCase extends CakeTestCase {

public $name = 'FixturizedTestCase';

public $fixtures = array('core.category');

public function testFixturePresent() {
$this->assertType('CakeFixtureManager', $this->sharedFixture);
//debug($this->sharedFixture);
}


public function testFixtureLoadOnDemand() {
$this->loadFixtures('Category');
}
}
4 changes: 1 addition & 3 deletions cake/tests/lib/cake_test_case.php
Expand Up @@ -195,9 +195,7 @@ function loadFixtures() {
}
$args = func_get_args();
foreach ($args as $class) {
if (!empty($this->sharedFixture)) {
$this->sharedFixture->unload($this);
}
$this->sharedFixture->loadSingle($class);
}
}

Expand Down

0 comments on commit 4d3a6e8

Please sign in to comment.