コード例 #1
0
ファイル: StackTest.php プロジェクト: Mosaic/Mosaic
 public function test_run_a_request_through_the_stack()
 {
     $this->app->shouldReceive('getContainer')->andReturn($this->container);
     $this->container->shouldReceive('make')->with(ReturnNext::class)->once()->andReturn(new ReturnNext());
     $this->container->shouldReceive('make')->with(ReturnSomeResponse::class)->once()->andReturn(new ReturnSomeResponse());
     $response = $this->stack->run($this->request)->through([ReturnNext::class, ReturnSomeResponse::class]);
     $this->assertEquals('Html body', $response->body());
 }
コード例 #2
0
ファイル: ServerTest.php プロジェクト: Mosaic/Mosaic
 private function setUpDependencies(bool $fail = false)
 {
     $dispatcher = \Mockery::mock(DispatchRequest::class);
     $dispatcher->shouldReceive('__invoke')->once()->andReturn($response = new Response(new ZendResponse()));
     $container = \Mockery::mock(Container::class);
     $container->shouldReceive('make')->with(Request::class)->andReturn(\Mockery::mock(Request::class));
     $container->shouldReceive('make')->with(DispatchRequest::class)->once()->andReturn($dispatcher);
     $this->app->shouldReceive('getContainer')->andReturn($container);
     $this->app->shouldReceive('setExceptionRunner')->once()->with(\Mockery::type(ExceptionRunner::class));
     $this->app->shouldReceive('setContext')->once()->with('web');
     $this->app->shouldReceive('bootstrap')->once();
     if ($fail) {
         $this->emitter->shouldReceive('emit')->andThrow(\InvalidArgumentException::class);
     } else {
         $this->emitter->shouldReceive('emit')->with($response, 1)->once();
     }
 }