Browse Source

Add explicit test for #3425

Ensure the association name does not take the class name
AD7six 11 years ago
parent
commit
67410cd213
1 changed files with 19 additions and 0 deletions
  1. 19 0
      tests/TestCase/ORM/TableTest.php

+ 19 - 0
tests/TestCase/ORM/TableTest.php

@@ -498,6 +498,25 @@ class TableTest extends TestCase
     }
 
     /**
+     * Test has one with a plugin model
+     *
+     * @return void
+     */
+    public function testHasOnePlugin()
+    {
+        $options = ['className' => 'TestPlugin.Comments'];
+        $table = new Table(['table' => 'users']);
+
+        $hasOne = $table->hasOne('Comments', $options);
+        $this->assertInstanceOf('Cake\ORM\Association\HasOne', $hasOne);
+        $this->assertSame('Comments', $hasOne->name());
+
+        $hasOneTable = $hasOne->target();
+        $this->assertSame('Comments', $hasOne->alias());
+        $this->assertSame('TestPlugin.Comments', $hasOne->registryAlias());
+    }
+
+    /**
      * Tests that hasMany() creates and configures correctly the association
      *
      * @return void