From 0a0ba598e514754e89af3e88c79c59486871ed83 Mon Sep 17 00:00:00 2001 From: "renan.saddam" Date: Sat, 27 Sep 2008 02:38:15 +0000 Subject: [PATCH] Proving that ClassRegistry will not overwrite alias from associations. Closes #5482 as invalid. git-svn-id: https://svn.cakephp.org/repo/branches/1.2.x.x@7670 3807eeeb-6ff5-0310-8944-8be069107fe0 --- cake/tests/cases/libs/class_registry.test.php | 42 +++++++++++++++++-- 1 file changed, 38 insertions(+), 4 deletions(-) diff --git a/cake/tests/cases/libs/class_registry.test.php b/cake/tests/cases/libs/class_registry.test.php index 8ae0efbba..da3161d96 100644 --- a/cake/tests/cases/libs/class_registry.test.php +++ b/cake/tests/cases/libs/class_registry.test.php @@ -67,10 +67,10 @@ class RegisterArticleFeatured extends ClassRegisterModel { /** * name property * - * @var string 'RegisterArticlFeatured' + * @var string 'RegisterArticleFeatured' * @access public */ - var $name = 'RegisterArticlFeatured'; + var $name = 'RegisterArticleFeatured'; } /** * RegisterArticleTag class @@ -82,10 +82,10 @@ class RegisterArticleTag extends ClassRegisterModel { /** * name property * - * @var string 'RegisterArticlTag' + * @var string 'RegisterArticleTag' * @access public */ - var $name = 'RegisterArticlTag'; + var $name = 'RegisterArticleTag'; } /** * RegistryPluginAppModel class @@ -117,6 +117,21 @@ class TestRegistryPluginModel extends RegistryPluginAppModel { */ var $name = 'TestRegistryPluginModel'; } +/** + * RegisterCategory class + * + * @package cake.tests + * @subpackage cake.tests.cases.libs + */ +class RegisterCategory extends ClassRegisterModel { +/** + * name property + * + * @var string 'RegisterCategory' + * @access public + */ + var $name = 'RegisterCategory'; +} /** * ClassRegistryTest class * @@ -191,6 +206,25 @@ class ClassRegistryTest extends CakeTestCase { } $this->assertTrue(is_a($UserCopy, 'AppModel')); $this->assertIdentical($User, $UserCopy); + + if (PHP5) { + $Category = ClassRegistry::init(array('class' => 'RegisterCategory')); + } else { + $Category =& ClassRegistry::init(array('class' => 'RegisterCategory')); + } + $this->assertTrue(is_a($Category, 'RegisterCategory')); + + if (PHP5) { + $ParentCategory = ClassRegistry::init(array('class' => 'RegisterCategory', 'alias' => 'ParentCategory')); + } else { + $ParentCategory =& ClassRegistry::init(array('class' => 'RegisterCategory', 'alias' => 'ParentCategory')); + } + $this->assertTrue(is_a($ParentCategory, 'RegisterCategory')); + $this->assertNotIdentical($Category, $ParentCategory); + + $this->assertNotEqual($Category->alias, $ParentCategory->alias); + $this->assertEqual('RegisterCategory', $Category->alias); + $this->assertEqual('ParentCategory', $ParentCategory->alias); } /** * testClassRegistryFlush method