Browse Source

Invalid table assertion.

Robert Pustułka 9 years ago
parent
commit
45cc8da998
1 changed files with 25 additions and 0 deletions
  1. 25 0
      tests/TestCase/ORM/AssociationTest.php

+ 25 - 0
tests/TestCase/ORM/AssociationTest.php

@@ -142,6 +142,31 @@ class AssociationTest extends TestCase
     }
 
     /**
+     * Tests that an exception is thrown when invalid target table is fetched
+     * from a registry.
+     *
+     * @return void
+     * @expectedException \RuntimeException
+     */
+    public function testInvalidTableFetchedFromRegistry()
+    {
+        TableRegistry::get('Test');
+
+        $config = [
+            'className' => '\Cake\Test\TestCase\ORM\TestTable',
+        ];
+        $this->association = $this->getMockBuilder('\Cake\ORM\Association')
+            ->setMethods([
+                '_options', 'attachTo', '_joinCondition', 'cascadeDelete', 'isOwningSide',
+                'saveAssociated', 'eagerLoader', 'type', 'requiresKeys'
+            ])
+            ->setConstructorArgs(['Test', $config])
+            ->getMock();
+
+        $this->association->getTarget();
+    }
+
+    /**
      * Tests that cascadeCallbacks() returns the correct configured value
      *
      * @return void