diff --git a/tests/TestCase/ORM/TableTest.php b/tests/TestCase/ORM/TableTest.php index fc9e0b73b15..7d40b82787f 100644 --- a/tests/TestCase/ORM/TableTest.php +++ b/tests/TestCase/ORM/TableTest.php @@ -521,8 +521,7 @@ public function testHasMany() } /** - * Should a dupicate short-named association be defined, the earlier - * association will be inaccessible via the __get method + * Ensure associations use the plugin-prefixed model * * @return void */ @@ -533,11 +532,25 @@ public function testHasManyPluginOverlap() $table = new Table(['table' => 'authors']); - $table->hasOne('Comments'); + $table->hasMany('TestPlugin.Comments'); $comments = $table->Comments->target(); - $this->assertInstanceOf('Cake\ORM\Table', $comments); + $this->assertInstanceOf('TestPlugin\Model\Table\CommentsTable', $comments); + } - $table->hasMany('TestPlugin.Comments'); + /** + * Ensure associations use the plugin-prefixed model + * even if specified with config + * + * @return void + */ + public function testHasManyPluginOverlapConfig() + { + TableRegistry::get('Comments'); + Plugin::load('TestPlugin'); + + $table = new Table(['table' => 'authors']); + + $table->hasMany('Comments', ['className' => 'TestPlugin.Comments']); $comments = $table->Comments->target(); $this->assertInstanceOf('TestPlugin\Model\Table\CommentsTable', $comments); }