From 71b7d6211bb9660bc34423bace5146f76cf2427d Mon Sep 17 00:00:00 2001 From: mark_story Date: Sat, 19 Nov 2016 22:30:18 -0400 Subject: [PATCH 1/2] Fix AclNode constructor. It should forward the settings from ClassRegistry::init() so that aliases can be customized as needed. Refs #9766 --- lib/Cake/Model/AclNode.php | 4 ++-- lib/Cake/Test/Case/Utility/ClassRegistryTest.php | 13 +++++++++++++ 2 files changed, 15 insertions(+), 2 deletions(-) diff --git a/lib/Cake/Model/AclNode.php b/lib/Cake/Model/AclNode.php index 1080b9a22..4d62dea87 100644 --- a/lib/Cake/Model/AclNode.php +++ b/lib/Cake/Model/AclNode.php @@ -40,12 +40,12 @@ class AclNode extends Model { /** * Constructor */ - public function __construct() { + public function __construct($id = false, $table = null, $ds = null) { $config = Configure::read('Acl.database'); if (isset($config)) { $this->useDbConfig = $config; } - parent::__construct(); + parent::__construct($id, $table, $ds); } /** diff --git a/lib/Cake/Test/Case/Utility/ClassRegistryTest.php b/lib/Cake/Test/Case/Utility/ClassRegistryTest.php index d6d70774f..fc3fdb18b 100644 --- a/lib/Cake/Test/Case/Utility/ClassRegistryTest.php +++ b/lib/Cake/Test/Case/Utility/ClassRegistryTest.php @@ -200,6 +200,19 @@ class ClassRegistryTest extends CakeTestCase { $this->assertSame('RegisterArticleTag', $newTag->name); } +/** + * Test that init() can make the Aco models with alias set properly + * + * @return void + */ + public function testAddModelWithAliasAco() + { + $aco = ClassRegistry::init(array('class' => 'Aco', 'alias' => 'CustomAco')); + $this->assertInstanceOf('Aco', $aco); + $this->assertSame('Aco', $aco->name); + $this->assertSame('CustomAco', $aco->alias); + } + /** * testClassRegistryFlush method * From e057b5572cfb94773b6a33f728b3369c1d6b4d4f Mon Sep 17 00:00:00 2001 From: mark_story Date: Mon, 21 Nov 2016 20:51:12 -0500 Subject: [PATCH 2/2] Fix PHPCS. --- lib/Cake/Model/AclNode.php | 5 +++++ lib/Cake/Test/Case/Utility/ClassRegistryTest.php | 6 ++---- 2 files changed, 7 insertions(+), 4 deletions(-) diff --git a/lib/Cake/Model/AclNode.php b/lib/Cake/Model/AclNode.php index 4d62dea87..a689ffe0e 100644 --- a/lib/Cake/Model/AclNode.php +++ b/lib/Cake/Model/AclNode.php @@ -39,6 +39,11 @@ class AclNode extends Model { /** * Constructor + * + * @param bool|int|string|array $id Set this ID for this model on startup, + * can also be an array of options, see above. + * @param string $table Name of database table to use. + * @param string $ds DataSource connection name. */ public function __construct($id = false, $table = null, $ds = null) { $config = Configure::read('Acl.database'); diff --git a/lib/Cake/Test/Case/Utility/ClassRegistryTest.php b/lib/Cake/Test/Case/Utility/ClassRegistryTest.php index fc3fdb18b..8587b3ef3 100644 --- a/lib/Cake/Test/Case/Utility/ClassRegistryTest.php +++ b/lib/Cake/Test/Case/Utility/ClassRegistryTest.php @@ -187,8 +187,7 @@ class ClassRegistryTest extends CakeTestCase { * * @return void */ - public function testAddModelWithAlias() - { + public function testAddModelWithAlias() { $tag = ClassRegistry::init(array('class' => 'RegisterArticleTag', 'alias' => 'NewTag')); $this->assertInstanceOf('RegisterArticleTag', $tag); $this->assertSame('NewTag', $tag->alias); @@ -205,8 +204,7 @@ class ClassRegistryTest extends CakeTestCase { * * @return void */ - public function testAddModelWithAliasAco() - { + public function testAddModelWithAliasAco() { $aco = ClassRegistry::init(array('class' => 'Aco', 'alias' => 'CustomAco')); $this->assertInstanceOf('Aco', $aco); $this->assertSame('Aco', $aco->name);