Skip to content

Commit 66363e6

Browse files
committed
Add tests for #9766
I'm not able to reproduce incorrect aliases coming out of ClassRegistry. As reported.
1 parent 93e29e9 commit 66363e6

File tree

1 file changed

+19
-1
lines changed

1 file changed

+19
-1
lines changed

lib/Cake/Test/Case/Utility/ClassRegistryTest.php

Lines changed: 19 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -147,7 +147,7 @@ public function testAddModel() {
147147
$this->assertSame($Tag, $TagCopy);
148148

149149
$NewTag = ClassRegistry::init(array('class' => 'RegisterArticleTag', 'alias' => 'NewTag'));
150-
$this->assertInstanceOf('RegisterArticleTag', $Tag);
150+
$this->assertInstanceOf('RegisterArticleTag', $NewTag);
151151

152152
$NewTagCopy = ClassRegistry::init(array('class' => 'RegisterArticleTag', 'alias' => 'NewTag'));
153153

@@ -182,6 +182,24 @@ public function testAddModel() {
182182
$this->assertEquals('ParentCategory', $ParentCategory->alias);
183183
}
184184

185+
/**
186+
* Test that init() can make models with alias set properly
187+
*
188+
* @return void
189+
*/
190+
public function testAddModelWithAlias()
191+
{
192+
$tag = ClassRegistry::init(array('class' => 'RegisterArticleTag', 'alias' => 'NewTag'));
193+
$this->assertInstanceOf('RegisterArticleTag', $tag);
194+
$this->assertSame('NewTag', $tag->alias);
195+
$this->assertSame('RegisterArticleTag', $tag->name);
196+
197+
$newTag = ClassRegistry::init(array('class' => 'RegisterArticleTag', 'alias' => 'OtherTag'));
198+
$this->assertInstanceOf('RegisterArticleTag', $tag);
199+
$this->assertSame('OtherTag', $newTag->alias);
200+
$this->assertSame('RegisterArticleTag', $newTag->name);
201+
}
202+
185203
/**
186204
* testClassRegistryFlush method
187205
*

0 commit comments

Comments
 (0)