/** * @dataProvider responseDataProvider * @param int $statusCode * @param array $responseHeaders */ public function test_get_return_the_response_we_expected($statusCode, array $responseHeaders) { // Given $mockHttpClient = $this->mockHttpClient($statusCode, $responseHeaders); $restApiContext = new SUT('http://verylastroom.com', $mockHttpClient); // When $restApiContext->sendRequest('GET', 'http://verylastroom.com/'); // Then $response = $restApiContext->getResponse(); $intersect = array_intersect_key($responseHeaders, $response->getHeaders()); $this->array($responseHeaders)->isEqualTo($intersect); }
/** * @dataProvider formDataUseCase */ public function test_we_can_send_body_as_form_data($formData, $expectedBody) { $this->given($mockHttpAdapter = $this->mockHttpClient('http://verylastroom.com', 200, []), $restApiBrowser = new SUT(null, null, $mockHttpAdapter))->when($restApiBrowser->sendRequest('POST', '/api', $formData))->then->castToString($mockHttpAdapter->getReceivedRequests()[0]->getBody())->isEqualTo($expectedBody); }