Browse Source

Improving the ExistsIn exception message. See #9157

Florian Krämer 9 years ago
parent
commit
1e05296af5
2 changed files with 4 additions and 3 deletions
  1. 3 2
      src/ORM/Rule/ExistsIn.php
  2. 1 1
      tests/TestCase/ORM/RulesCheckerIntegrationTest.php

+ 3 - 2
src/ORM/Rule/ExistsIn.php

@@ -67,9 +67,10 @@ class ExistsIn
             $repository = $options['repository']->association($this->_repository);
             if (!$repository) {
                 throw new RuntimeException(sprintf(
-                    "ExistsIn rule for '%s' is invalid. The '%s' association is not defined.",
+                    "ExistsIn rule for '%s' is invalid. '%s' is not associated with '%s'.",
                     implode(', ', $this->_fields),
-                    $this->_repository
+                    $this->_repository,
+                    get_class($options['repository'])
                 ));
             }
             $this->_repository = $repository;

+ 1 - 1
tests/TestCase/ORM/RulesCheckerIntegrationTest.php

@@ -568,7 +568,7 @@ class RulesCheckerIntegrationTest extends TestCase
      *
      * @group save
      * @expectedException RuntimeException
-     * @expectedExceptionMessage ExistsIn rule for 'author_id' is invalid. The 'NotValid' association is not defined.
+     * @expectedExceptionMessage ExistsIn rule for 'author_id' is invalid. 'NotValid' is not associated with 'Cake\ORM\Table'.
      * @return void
      */
     public function testExistsInInvalidAssociation()