Skip to content

Commit

Permalink
Add tests for #9766
Browse files Browse the repository at this point in the history
I'm not able to reproduce incorrect aliases coming out of ClassRegistry.
As reported.
  • Loading branch information
markstory committed Nov 19, 2016
1 parent 93e29e9 commit 66363e6
Showing 1 changed file with 19 additions and 1 deletion.
20 changes: 19 additions & 1 deletion lib/Cake/Test/Case/Utility/ClassRegistryTest.php
Expand Up @@ -147,7 +147,7 @@ public function testAddModel() {
$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'));

Expand Down Expand Up @@ -182,6 +182,24 @@ public function testAddModel() {
$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
*
Expand Down

0 comments on commit 66363e6

Please sign in to comment.