getMockBuilder(Request::class) ->disableOriginalConstructor() ->setMethods([]) ->getMock(); $mock->query = new Collection($get); $mock->data = new Collection($post); $mock->files = new Collection($files); return $mock; } protected function getResponse() { /** @var Response|\PHPUnit_Framework_MockObject_MockObject $mock */ $mock = $this->getMockBuilder(Response::class) ->disableOriginalConstructor() ->setMethods(['send']) ->getMock(); $mock->expects($this->any()) ->method('send') ->willReturnCallback(function () use ($mock) { $reflection = new \ReflectionClass($mock); $bodyProperty = $reflection->getProperty('body'); $bodyProperty->setAccessible(true); $this->responseData = $bodyProperty->getValue($mock); }); return $mock; } protected function getResponseData() { return $this->responseData; } protected function assertResponseData($expected) { if (!is_string($expected)) { $expected = json_encode($expected); } $this->assertEquals($expected, $this->getResponseData()); } }