From 44d74ec03031ad5f976b230006e3a1533622dc8c Mon Sep 17 00:00:00 2001 From: Brian Porter Date: Thu, 28 Jan 2016 11:18:38 -0600 Subject: [PATCH] Add an example test. This test will error without the `(array)` cast in the previous commit. --- tests/TestCase/View/Form/FormContextTest.php | 14 +++++++++++++- 1 file changed, 13 insertions(+), 1 deletion(-) diff --git a/tests/TestCase/View/Form/FormContextTest.php b/tests/TestCase/View/Form/FormContextTest.php index e606f15d5f2..e14697e5de4 100644 --- a/tests/TestCase/View/Form/FormContextTest.php +++ b/tests/TestCase/View/Form/FormContextTest.php @@ -196,9 +196,21 @@ public function testError() $this->assertEquals(['The provided value is invalid'], $context->error('email')); $this->assertEquals(['The provided value is invalid'], $context->error('name')); $this->assertEquals(['The provided value is invalid'], $context->error('pass.password')); - $this->assertEquals([], $context->error('Alias.name')); $this->assertEquals([], $context->error('nope.nope')); + + $mock = $this->getMock('Cake\Validation\Validator', ['errors']); + $mock->expects($this->once()) + ->method('errors') + ->willReturn(['key' => 'should be an array, not a string']); + $form->validator($mock); + $form->validate([]); + $context = new FormContext($this->request, ['entity' => $form]); + $this->assertEquals( + ['should be an array, not a string'], + $context->error('key'), + 'This test should not produce a PHP warning from array_values().' + ); } /**