Skip to content
Permalink
Browse files

Improve error message.

  • Loading branch information...
ADmad committed Aug 8, 2017
1 parent 8ee647f commit 89250d1dd2896b26e70c13466da1b8d07f4ac56e
Showing with 6 additions and 4 deletions.
  1. +5 −3 src/View/Form/ContextFactory.php
  2. +1 −1 tests/TestCase/View/Helper/FormHelperTest.php
@@ -141,9 +141,11 @@ public function get(ServerRequest $request, array $data = [])
$context = new NullContext($request, $data);
}
if (!($context instanceof ContextInterface)) {
throw new RuntimeException(
'Context objects must implement Cake\View\Form\ContextInterface'
);
throw new RuntimeException(sprintf(
'Context providers must return object implementing %s. Got "%s" instead.',
'Cake\View\Form\ContextInterface',
is_object($context) ? get_class($context) : gettype($context)
));
}
return $context;
@@ -386,7 +386,7 @@ public function testAddContextProviderAdd()
* Test adding an invalid context class.
*
* @expectedException \RuntimeException
* @expectedExceptionMessage Context objects must implement Cake\View\Form\ContextInterface
* @expectedExceptionMessage Context providers must return object implementing Cake\View\Form\ContextInterface. Got "stdClass" instead.
* @return void
*/
public function testAddContextProviderInvalid()

0 comments on commit 89250d1

Please sign in to comment.
You can’t perform that action at this time.