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


PHP GetResponseForExceptionEvent::expects方法代码示例

本文整理汇总了PHP中Symfony\Component\HttpKernel\Event\GetResponseForExceptionEvent::expects方法的典型用法代码示例。如果您正苦于以下问题:PHP GetResponseForExceptionEvent::expects方法的具体用法?PHP GetResponseForExceptionEvent::expects怎么用?PHP GetResponseForExceptionEvent::expects使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Symfony\Component\HttpKernel\Event\GetResponseForExceptionEvent的用法示例。


在下文中一共展示了GetResponseForExceptionEvent::expects方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: testOnKernelException

 public function testOnKernelException()
 {
     $response = $this->getMock(Response::class);
     $exception = $this->getNoConstructorMock(NotModifiedException::class);
     $exception->expects($this->once())->method('getResponse')->will($this->returnValue($response));
     $this->event->expects($this->once())->method('getException')->will($this->returnValue($exception));
     $this->event->expects($this->once())->method('setResponse')->with($response);
     $this->listener->onKernelException($this->event);
 }
开发者ID:anime-db,项目名称:cache-time-keeper-bundle,代码行数:9,代码来源:ExceptionListenerTest.php

示例2: setUp

 /**
  * Set up mocking
  */
 protected function setUp()
 {
     $this->exception = new \Exception("Mary had a little lamb");
     $reflection = new \ReflectionClass($this->exception);
     $codeProperty = $reflection->getProperty('code');
     $this->codeProperty = $codeProperty;
     $this->codeProperty->setAccessible(true);
     $this->event = $this->getMockBuilder('Symfony\\Component\\HttpKernel\\Event\\GetResponseForExceptionEvent')->disableOriginalConstructor()->setMethods(['getException'])->getMock();
     $this->event->expects($this->any())->method('getException')->willReturn($this->exception);
     /** @var LoggerInterface $logger */
     $logger = $this->getMockForAbstractClass('Psr\\Log\\LoggerInterface');
     $this->exceptionListener = new ExceptionListener($logger);
 }
开发者ID:krizon,项目名称:swagger-bundle,代码行数:16,代码来源:ExceptionListenerTest.php

示例3: 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

示例4: setUp

 /**
  * Set up mocking
  */
 protected function setUp()
 {
     $this->event = $this->getMockBuilder(GetResponseForExceptionEvent::class)->disableOriginalConstructor()->setMethods(['getException', 'getRequest'])->getMock();
     $this->exception = new \Exception("Mary had a little lamb");
     $reflection = new \ReflectionClass($this->exception);
     $codeProperty = $reflection->getProperty('code');
     $this->codeProperty = $codeProperty;
     $this->codeProperty->setAccessible(true);
     $attributes = [RequestMeta::ATTRIBUTE_URI => '/foo/bar'];
     $this->request = new Request($query = [], $request = [], $attributes);
     $this->event->expects($this->any())->method('getException')->willReturn($this->exception);
     $this->event->expects($this->any())->method('getRequest')->willReturn($this->request);
     /** @var ErrorResponseFactory $errorResponseFactory */
     $errorResponseFactory = $this->getMockBuilder(ErrorResponseFactory::class)->disableOriginalConstructor()->getMock();
     /** @var LogRefBuilder $logRefBuilder */
     $lofRefBuilderMock = $logRefBuilder = $this->getMockForAbstractClass(LogRefBuilder::class);
     $lofRefBuilderMock->expects($this->any())->method('create')->willReturn((string) rand());
     $this->logger = $this->getMockForAbstractClass(LoggerInterface::class);
     $this->exceptionListener = new ExceptionListener($errorResponseFactory, $logRefBuilder, $this->logger);
 }
开发者ID:kleijnweb,项目名称:swagger-bundle,代码行数:23,代码来源:ExceptionListenerTest.php


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