Esempio n. 1
0
 protected function validateSerializer(array $serializerMap)
 {
     $this->serializer->expects($this->any())->method('serialize')->will($this->returnCallback(function ($data) use($serializerMap) {
         foreach ($serializerMap as $entry) {
             if ($data == $entry['data']) {
                 return $entry['result'];
             }
         }
         return '';
     }));
 }
 /**
  * Test RqlOperatorNotAllowedListener::onKernelException()
  *
  * @return void
  */
 public function testOnKernelException()
 {
     $serializedContent = 'serialized content';
     $response = $this->getMockBuilder(Response::class)->disableOriginalConstructor()->getMock();
     $response->expects($this->once())->method('setStatusCode')->with(Response::HTTP_BAD_REQUEST)->willReturnSelf();
     $response->expects($this->once())->method('setContent')->with($serializedContent)->willReturnSelf();
     $exception = new RqlOperatorNotAllowedException('limit');
     $exception->setResponse($response);
     $this->serializer->expects($this->once())->method('serialize')->with(['message' => $exception->getMessage()], 'json', $this->context)->willReturn($serializedContent);
     $this->event->expects($this->once())->method('getException')->willReturn($exception);
     $this->event->expects($this->once())->method('setResponse');
     $listener = new RqlOperatorNotAllowedListener($this->serializer, $this->context);
     $listener->onKernelException($this->event);
 }
Esempio n. 3
0
 /**
  * @param mixed        $data
  * @param string       $type
  * @param string       $format
  * @param Context|null $context
  * @dataProvider provideDeserializationData
  */
 public function testDeserialize($data, $type, $format, $context = null)
 {
     $this->serializer->expects($this->once())->method('deserialize')->with($data, $type, $format, $context);
     $this->subject->deserialize($data, $type, $format, $context);
 }