From 3bfdfa68b42c182f391a683b4d2a862f4c9cecaf Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Micha=C3=ABl=20Gallego?= Date: Wed, 2 Apr 2014 10:43:05 +0200 Subject: [PATCH] Fix test --- .../Mvc/ControllerWithValidationGroupSpec.php | 36 +++++++++++++++++++ .../MethodHandler/DataValidationTraitTest.php | 9 ++--- 2 files changed, 39 insertions(+), 6 deletions(-) create mode 100644 tests/ZfrRestTest/Asset/Mvc/ControllerWithValidationGroupSpec.php diff --git a/tests/ZfrRestTest/Asset/Mvc/ControllerWithValidationGroupSpec.php b/tests/ZfrRestTest/Asset/Mvc/ControllerWithValidationGroupSpec.php new file mode 100644 index 0000000..cc7da21 --- /dev/null +++ b/tests/ZfrRestTest/Asset/Mvc/ControllerWithValidationGroupSpec.php @@ -0,0 +1,36 @@ + ['field'] + ]; + } +} diff --git a/tests/ZfrRestTest/Mvc/Controller/MethodHandler/DataValidationTraitTest.php b/tests/ZfrRestTest/Mvc/Controller/MethodHandler/DataValidationTraitTest.php index 3e4051f..71609a0 100644 --- a/tests/ZfrRestTest/Mvc/Controller/MethodHandler/DataValidationTraitTest.php +++ b/tests/ZfrRestTest/Mvc/Controller/MethodHandler/DataValidationTraitTest.php @@ -20,6 +20,7 @@ use PHPUnit_Framework_TestCase; use ZfrRest\Options\ControllerBehavioursOptions; +use ZfrRestTest\Asset\Mvc\ControllerWithValidationGroupSpec; use ZfrRestTest\Asset\Mvc\DataValidationObject; /** @@ -120,18 +121,12 @@ public function testThrowExceptionOnFailedValidation() public function testCanUseValidationGroup() { - $controller = $this->getMock('ZfrRest\Mvc\Controller\AbstractRestfulController'); - $resource = $this->getMock('ZfrRest\Resource\ResourceInterface'); $metadata = $this->getMock('ZfrRest\Resource\Metadata\ResourceMetadataInterface'); $resource->expects($this->once())->method('getMetadata')->will($this->returnValue($metadata)); $metadata->expects($this->once())->method('getInputFilterName')->will($this->returnValue('inputFilter')); - $controller->expects($this->once()) - ->method('getValidationGroupSpecification') - ->will($this->returnValue(['post' => ['field']])); - $data = ['foo']; $inputFilter = $this->getMock('Zend\InputFilter\InputFilterInterface'); @@ -153,6 +148,8 @@ public function testCanUseValidationGroup() ->method('getValues') ->will($this->returnValue(['filtered'])); + $controller = new ControllerWithValidationGroupSpec(); + $result = $this->dataValidation->validateData($resource, $data, $controller, 'post'); $this->assertEquals(['filtered'], $result);