raiseThrowables() 공개 메소드

Enables the "raise throwables", causing this instance to raise throwables instead of catch them.
public raiseThrowables ( ) : void
리턴 void
예제 #1
0
 /**
  * Toggle the "raise throwables" flag on.
  *
  * @return void
  */
 public function raiseThrowables()
 {
     $this->raiseThrowables = true;
     $this->dispatch->raiseThrowables();
 }
 /**
  * @dataProvider throwablesProvider
  * @group error-handling
  */
 public function testThrowsThrowablesRaisedByInteropMiddlewareWhenRaiseThrowablesFlagIsEnabled($throwable)
 {
     $middleware = $this->prophesize(ServerMiddlewareInterface::class);
     $middleware->process(Argument::type(ServerRequestInterface::class), Argument::type(DelegateInterface::class))->will(function () use($throwable) {
         throw $throwable;
     });
     $route = new Route('/', $middleware->reveal());
     $next = $this->prophesize(Next::class);
     $next->__invoke(Argument::type(ServerRequestInterface::class), Argument::type(ResponseInterface::class), $throwable)->shouldNotBeCalled();
     $dispatch = new Dispatch();
     $dispatch->raiseThrowables();
     try {
         $dispatch->process($route, $this->request->reveal(), $next->reveal());
         $this->fail('Dispatch succeeded and should not have');
     } catch (\Throwable $e) {
         $this->assertSame($throwable, $e, sprintf('Throwable raised is not the one expected: %s', $e->getMessage()));
     } catch (\Exception $e) {
         $this->assertSame($throwable, $e, sprintf('Exception raised is not the one expected: %s', $e->getMessage()));
     }
 }