当前位置: 首页>>代码示例>>PHP>>正文


PHP SerializerInterface::expects方法代码示例

本文整理汇总了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 '';
     }));
 }
开发者ID:xabbuh,项目名称:xapi-client,代码行数:11,代码来源:ApiClientTest.php

示例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);
 }
开发者ID:alebon,项目名称:graviton,代码行数:19,代码来源:RqlOperatorNotAllowedListenerTest.php

示例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);
 }
开发者ID:aboutcoders,项目名称:job-bundle,代码行数:12,代码来源:SerializerTest.php


注:本文中的JMS\Serializer\SerializerInterface::expects方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。