Author: Kévin Dunglas (dunglas@gmail.com)
 public function testEncode()
 {
     $serializerProphecy = $this->prophesize(SerializerInterface::class);
     $serializerProphecy->willImplement(EncoderInterface::class);
     $serializerProphecy->encode(Argument::any(), 'xml')->willReturn('bar')->shouldBeCalled();
     $serializerProphecy->serialize()->shouldNotBeCalled();
     $request = new Request([], [], ['_api_respond' => true]);
     $request->setRequestFormat('xml');
     $eventProphecy = $this->prophesize(GetResponseForControllerResultEvent::class);
     $eventProphecy->getControllerResult()->willReturn([])->shouldBeCalled();
     $eventProphecy->getRequest()->willReturn($request)->shouldBeCalled();
     $eventProphecy->setControllerResult('bar')->shouldBeCalled();
     $serializerContextBuilderProphecy = $this->prophesize(SerializerContextBuilderInterface::class);
     $listener = new SerializeListener($serializerProphecy->reveal(), $serializerContextBuilderProphecy->reveal());
     $listener->onKernelView($eventProphecy->reveal());
 }