mirror of
https://github.com/kamilwylegala/cakephp2-php8.git
synced 2025-01-18 10:36:16 +00:00
Fixed issue where ClassRegistry alias was incorrectly set
This commit is contained in:
parent
c970770c8d
commit
e99f090ee0
2 changed files with 33 additions and 3 deletions
|
@ -76,6 +76,20 @@ if (!class_exists('PostsController')) {
|
|||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* ControllerTestCaseTest controller
|
||||
*/
|
||||
class ControllerTestCaseTestController extends AppController {
|
||||
|
||||
/**
|
||||
* Uses array
|
||||
*
|
||||
* @param array
|
||||
*/
|
||||
public $uses = array('TestPlugin.TestPluginComment');
|
||||
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* ControllerTestCaseTest
|
||||
|
@ -90,7 +104,7 @@ class ControllerTestCaseTest extends CakeTestCase {
|
|||
* @var array
|
||||
* @access public
|
||||
*/
|
||||
public $fixtures = array('core.post', 'core.author');
|
||||
public $fixtures = array('core.post', 'core.author', 'core.test_plugin_comment');
|
||||
|
||||
/**
|
||||
* reset environment.
|
||||
|
@ -201,6 +215,22 @@ class ControllerTestCaseTest extends CakeTestCase {
|
|||
|
||||
$result = ClassRegistry::init('TestPlugin.TestPluginComment');
|
||||
$this->assertInstanceOf('TestPluginComment', $result);
|
||||
|
||||
$Tests = $this->Case->generate('ControllerTestCaseTest', array(
|
||||
'models' => array(
|
||||
'TestPlugin.TestPluginComment' => array('save')
|
||||
)
|
||||
));
|
||||
$this->assertInstanceOf('TestPluginComment', $Tests->TestPluginComment);
|
||||
$Tests->TestPluginComment->expects($this->at(0))
|
||||
->method('save')
|
||||
->will($this->returnValue(true));
|
||||
$Tests->TestPluginComment->expects($this->at(1))
|
||||
->method('save')
|
||||
->will($this->returnValue(false));
|
||||
$this->assertTrue($Tests->TestPluginComment->save(array()));
|
||||
$this->assertFalse($Tests->TestPluginComment->save(array()));
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
@ -280,8 +280,8 @@ class ControllerTestCase extends CakeTestCase {
|
|||
list($plugin, $name) = pluginSplit($model);
|
||||
$config = array_merge((array)$config, array('name' => $model));
|
||||
$_model = $this->getMock($name, $methods, array($config));
|
||||
ClassRegistry::removeObject($model);
|
||||
ClassRegistry::addObject($model, $_model);
|
||||
ClassRegistry::removeObject($name);
|
||||
ClassRegistry::addObject($name, $_model);
|
||||
}
|
||||
|
||||
foreach ($mocks['components'] as $component => $methods) {
|
||||
|
|
Loading…
Add table
Reference in a new issue