本文整理匯總了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);
}