Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
Adding flush so models in registry are always fresh
fixes issues baking model + test
  • Loading branch information
markstory committed May 26, 2009
1 parent fe235f4 commit 2b6ea87
Show file tree
Hide file tree
Showing 2 changed files with 25 additions and 0 deletions.
1 change: 1 addition & 0 deletions cake/console/libs/tasks/test.php
Expand Up @@ -237,6 +237,7 @@ function isLoadableClass($type, $class) {
* @return object
**/
function &buildTestSubject($type, $class) {
ClassRegistry::flush();
App::import($type, $class);
$class = $this->getRealClassName($type, $class);
if (strtolower($type) == 'model') {
Expand Down
24 changes: 24 additions & 0 deletions cake/tests/cases/console/libs/tasks/test.test.php
Expand Up @@ -228,6 +228,30 @@ function testGetObjectType() {
$this->assertEqual($result, $this->Task->classTypes[1]);
}

/**
* creating test subjects should clear the registry so the registry is always fresh
*
* @return void
**/
function testRegistryClearWhenBuildingTestObjects() {
ClassRegistry::flush();
$model = ClassRegistry::init('TestTaskComment');
$model->bindModel(array(
'belongsTo' => array(
'Random' => array(
'className' => 'TestTaskArticle',
'foreignKey' => 'article_id',
)
)
));
$keys = ClassRegistry::keys();
$this->assertTrue(in_array('random', $keys));
$object =& $this->Task->buildTestSubject('Model', 'TestTaskComment');

$keys = ClassRegistry::keys();
$this->assertFalse(in_array('random', $keys));
}

/**
* test that getClassName returns the user choice as a classname.
*
Expand Down

0 comments on commit 2b6ea87

Please sign in to comment.