mirror of
https://github.com/kamilwylegala/cakephp2-php8.git
synced 2025-01-31 09:06:17 +00:00
Adding flush so models in registry are always fresh
fixes issues baking model + test
This commit is contained in:
parent
fe235f4e94
commit
2b6ea8748c
2 changed files with 25 additions and 0 deletions
|
@ -237,6 +237,7 @@ class TestTask extends Shell {
|
|||
* @return object
|
||||
**/
|
||||
function &buildTestSubject($type, $class) {
|
||||
ClassRegistry::flush();
|
||||
App::import($type, $class);
|
||||
$class = $this->getRealClassName($type, $class);
|
||||
if (strtolower($type) == 'model') {
|
||||
|
|
|
@ -228,6 +228,30 @@ class TestTaskTest extends CakeTestCase {
|
|||
$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.
|
||||
*
|
||||
|
|
Loading…
Add table
Reference in a new issue