本文整理汇总了PHP中JMS\Serializer\SerializerInterface::expects方法的典型用法代码示例。如果您正苦于以下问题:PHP SerializerInterface::expects方法的具体用法?PHP SerializerInterface::expects怎么用?PHP SerializerInterface::expects使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类JMS\Serializer\SerializerInterface
的用法示例。
在下文中一共展示了SerializerInterface::expects方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: validateSerializer
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 '';
}));
}
示例2: testOnKernelException
/**
* 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);
}
示例3: testDeserialize
/**
* @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);
}