middleware = new ChildMiddleware(); $this->api = $this->getMockBuilder(DIContainer::class) ->disableOriginalConstructor() ->getMock(); $this->controller = $this->getMockBuilder(Controller::class) ->setMethods([]) ->setConstructorArgs([ $this->api, new Request( [], $this->createMock(IRequestId::class), $this->createMock(IConfig::class) ) ])->getMock(); $this->exception = new \Exception(); $this->response = $this->getMockBuilder(Response::class)->getMock(); } public function testBeforeController(): void { $this->middleware->beforeController($this->controller, ''); $this->assertNull(null); } public function testAfterExceptionRaiseAgainWhenUnhandled(): void { $this->expectException(\Exception::class); $this->middleware->afterException($this->controller, '', $this->exception); } public function testAfterControllerReturnResponseWhenUnhandled(): void { $response = $this->middleware->afterController($this->controller, '', $this->response); $this->assertEquals($this->response, $response); } public function testBeforeOutputReturnOutputhenUnhandled(): void { $output = $this->middleware->beforeOutput($this->controller, '', 'test'); $this->assertEquals('test', $output); } }