Permalink
Browse files

Adding flush so models in registry are always fresh

fixes issues baking model + test
  • Loading branch information...
1 parent fe235f4 commit 2b6ea8748c330b059de849f64c613dca3ffb1996 @markstory markstory committed May 26, 2009
Showing with 25 additions and 0 deletions.
  1. +1 −0 cake/console/libs/tasks/test.php
  2. +24 −0 cake/tests/cases/console/libs/tasks/test.test.php
@@ -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') {
@@ -229,6 +229,30 @@ function testGetObjectType() {
}
/**
+ * 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.
*
* @return void

0 comments on commit 2b6ea87

Please sign in to comment.