Skip to content

Commit

Permalink
Changing the EntityRoute exception message
Browse files Browse the repository at this point in the history
  • Loading branch information
burzum committed Oct 8, 2017
1 parent ed3eadf commit c625d44
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 5 deletions.
6 changes: 2 additions & 4 deletions src/Routing/Route/EntityRoute.php
Expand Up @@ -15,7 +15,6 @@
namespace Cake\Routing\Route;

use ArrayAccess;
use Cake\Datasource\EntityInterface;
use RuntimeException;

/**
Expand Down Expand Up @@ -57,16 +56,15 @@ public function match(array $url, array $context = [])
* Checks that we really deal with an entity object
*
* @throws \RuntimeException
* @param mixed $entity Entity value from the URL options
* @param \ArrayAccess|array $entity Entity value from the URL options
* @return void
*/
protected function _checkEntity($entity)
{
if (!$entity instanceof ArrayAccess && !is_array($entity)) {
throw new RuntimeException(sprintf(
'Route `%s` expects the URL option `_entity` to be `%s`, but `%s` passed.',
'Route `%s` expects the URL option `_entity` to be an array or object implementing \ArrayAccess, but `%s` passed.',
$this->template,
EntityInterface::class,
is_object($entity) ? get_class($entity) : gettype($entity)
));
}
Expand Down
2 changes: 1 addition & 1 deletion tests/TestCase/Routing/Route/EntityRouteTest.php
Expand Up @@ -91,7 +91,7 @@ public function testMatchingArray()
* Test invalid entity option value
*
* @expectedException \RuntimeException
* @expectedExceptionMessage Route `/` expects the URL option `_entity` to be `Cake\Datasource\EntityInterface`, but `string` passed.
* @expectedExceptionMessage Route `/` expects the URL option `_entity` to be an array or object implementing \ArrayAccess, but `string` passed.
*/
public function testInvalidEntityValueException()
{
Expand Down

0 comments on commit c625d44

Please sign in to comment.