Add tests for #9766

I'm not able to reproduce incorrect aliases coming out of ClassRegistry.
As reported.
This commit is contained in:
mark_story 2016-11-19 10:02:09 -04:00
parent 93e29e91ef
commit 66363e6bea

View file

@ -147,7 +147,7 @@ class ClassRegistryTest extends CakeTestCase {
$this->assertSame($Tag, $TagCopy);
$NewTag = ClassRegistry::init(array('class' => 'RegisterArticleTag', 'alias' => 'NewTag'));
$this->assertInstanceOf('RegisterArticleTag', $Tag);
$this->assertInstanceOf('RegisterArticleTag', $NewTag);
$NewTagCopy = ClassRegistry::init(array('class' => 'RegisterArticleTag', 'alias' => 'NewTag'));
@ -182,6 +182,24 @@ class ClassRegistryTest extends CakeTestCase {
$this->assertEquals('ParentCategory', $ParentCategory->alias);
}
/**
* Test that init() can make models with alias set properly
*
* @return void
*/
public function testAddModelWithAlias()
{
$tag = ClassRegistry::init(array('class' => 'RegisterArticleTag', 'alias' => 'NewTag'));
$this->assertInstanceOf('RegisterArticleTag', $tag);
$this->assertSame('NewTag', $tag->alias);
$this->assertSame('RegisterArticleTag', $tag->name);
$newTag = ClassRegistry::init(array('class' => 'RegisterArticleTag', 'alias' => 'OtherTag'));
$this->assertInstanceOf('RegisterArticleTag', $tag);
$this->assertSame('OtherTag', $newTag->alias);
$this->assertSame('RegisterArticleTag', $newTag->name);
}
/**
* testClassRegistryFlush method
*