|
16 | 16 | use FOS\RestBundle\View\ViewHandler; |
17 | 17 | use Symfony\Bundle\FrameworkBundle\Templating\TemplateReference; |
18 | 18 | use FOS\Rest\Util\Codes; |
19 | | -use Symfony\Component\DependencyInjection\Container; |
20 | 19 | use Symfony\Component\HttpFoundation\Request; |
21 | 20 | use Symfony\Component\HttpFoundation\Response; |
22 | 21 | use Symfony\Component\Form\FormView; |
@@ -289,58 +288,6 @@ function ($method) use ($serializer) { |
289 | 288 | ->will($this->returnValueMap($map)); |
290 | 289 | } |
291 | 290 |
|
292 | | - public function testShouldReturnErrorResponseWhenDataContainsFormAndFormIsNotValid() |
293 | | - { |
294 | | - $container = new Container(); |
295 | | - |
296 | | - $serializer = $this->getMock('JMS\Serializer\Serializer', array(), array(), '', false); |
297 | | - $serializer |
298 | | - ->expects($this->once()) |
299 | | - ->method('serialize') |
300 | | - ->will( |
301 | | - $this->returnCallback( |
302 | | - function ($data) { |
303 | | - return serialize($data); |
304 | | - } |
305 | | - ) |
306 | | - ); |
307 | | - |
308 | | - $container->set('fos_rest.serializer', $serializer); |
309 | | - $container->set('fos_rest.view.exception_wrapper_handler', new ExceptionWrapperHandler()); |
310 | | - $container->setParameter('fos_rest.serializer.exclusion_strategy.groups', 'foo'); |
311 | | - $container->setParameter('fos_rest.serializer.exclusion_strategy.version', '1.0'); |
312 | | - $container->setParameter('fos_rest.serializer.serialize_null', false); |
313 | | - |
314 | | - //test |
315 | | - $viewHandler = new ViewHandler(null, $expectedFailedValidationCode = Codes::HTTP_I_AM_A_TEAPOT); |
316 | | - $viewHandler->setContainer($container); |
317 | | - |
318 | | - $form = $this->getMock( |
319 | | - 'Symfony\\Component\\Form\\Form', |
320 | | - array('createView', 'getData', 'isValid', 'isBound'), |
321 | | - array(), |
322 | | - '', |
323 | | - false |
324 | | - ); |
325 | | - $form |
326 | | - ->expects($this->any()) |
327 | | - ->method('isValid') |
328 | | - ->will($this->returnValue(false)); |
329 | | - $form |
330 | | - ->expects($this->any()) |
331 | | - ->method('isBound') |
332 | | - ->will($this->returnValue(true)); |
333 | | - |
334 | | - $view = new View($form); |
335 | | - $response = $viewHandler->createResponse($view, new Request, 'json'); |
336 | | - |
337 | | - $data = unserialize($response->getContent()); |
338 | | - $this->assertInstanceOf('FOS\\RestBundle\\Util\\ExceptionWrapper', $data); |
339 | | - $this->assertEquals('Validation Failed', $this->readAttribute($data, 'message')); |
340 | | - $this->assertInstanceOf('Symfony\\Component\\Form\\Form', $this->readAttribute($data, 'errors')); |
341 | | - $this->assertEquals($expectedFailedValidationCode, $this->readAttribute($data, 'code')); |
342 | | - } |
343 | | - |
344 | 291 | public static function createResponseWithoutLocationDataProvider() |
345 | 292 | { |
346 | 293 | return array( |
|
0 commit comments