Ejemplo n.º 1
0
 /**
  * @expectedException \Symfony\Component\HttpKernel\Exception\BadRequestHttpException
  */
 public function testOnKernelRequestNormalizationException()
 {
     $decoder = $this->getMock('FOS\\RestBundle\\Decoder\\DecoderInterface');
     $decoder->expects($this->any())->method('decode')->will($this->returnValue(array()));
     $decoderProvider = $this->getMock('FOS\\RestBundle\\Decoder\\DecoderProviderInterface');
     $decoderProvider->expects($this->any())->method('getDecoder')->will($this->returnValue($decoder));
     $decoderProvider->expects($this->any())->method('supports')->will($this->returnValue(true));
     $normalizer = $this->getMock('FOS\\RestBundle\\Normalizer\\ArrayNormalizerInterface');
     $normalizer->expects($this->once())->method('normalize')->will($this->throwException(new NormalizationException()));
     $request = new Request(array(), array(), array(), array(), array(), array(), 'foo');
     $request->setMethod('POST');
     $event = $this->getMockBuilder('Symfony\\Component\\HttpKernel\\Event\\GetResponseEvent')->disableOriginalConstructor()->getMock();
     $event->expects($this->once())->method('getRequest')->will($this->returnValue($request));
     $listener = new BodyListener($decoderProvider, false);
     $listener->setArrayNormalizer($normalizer);
     $listener->onKernelRequest($event);
 }