getMockBuilder(BrowserErrorPagePlugin::class)->onlyMethods(['sendResponse', 'generateBody'])->getMock(); $plugin->expects($this->once())->method('generateBody')->willReturn(':boom:'); $plugin->expects($this->once())->method('sendResponse'); /** @var \Sabre\DAV\Server&MockObject $server */ $server = $this->createMock('Sabre\DAV\Server'); $server->expects($this->once())->method('on'); $httpResponse = $this->createMock(Response::class); $httpResponse->expects($this->once())->method('addHeaders'); $httpResponse->expects($this->once())->method('setStatus')->with($expectedCode); $httpResponse->expects($this->once())->method('setBody')->with(':boom:'); $server->httpResponse = $httpResponse; $plugin->initialize($server); $plugin->logException($exception); } public static function providesExceptions(): array { return [ [ 404, new NotFound()], [ 500, new \RuntimeException()], ]; } }