Browse Source

Add test for new getAssociation() being strict.

dereuromark 8 years ago
parent
commit
8a612f2e00
1 changed files with 13 additions and 0 deletions
  1. 13 0
      tests/TestCase/ORM/TableTest.php

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

@@ -39,6 +39,7 @@ use Cake\ORM\Table;
 use Cake\ORM\TableRegistry;
 use Cake\TestSuite\TestCase;
 use Cake\Validation\Validator;
+use InvalidArgumentException;
 
 /**
  * Used to test correct class is instantiated when using TableRegistry::get();
@@ -644,6 +645,18 @@ class TableTest extends TestCase
     }
 
     /**
+     * Tests that the getAssociation() method throws an exception on non-existent ones.
+     *
+     * @return void
+     */
+    public function testGetAssociationNonExistent()
+    {
+        $this->expectException(InvalidArgumentException::class);
+
+        TableRegistry::get('Groups')->getAssociation('FooBar');
+    }
+
+    /**
      * Tests that belongsTo() creates and configures correctly the association
      *
      * @return void