/** * @depends testAddsRequests */ public function testMaintainsLimit() { $h = new HistoryPlugin(); $h->setLimit(2); $requests = $this->addRequests($h, 3); $this->assertEquals(2, count($h)); $i = 0; foreach ($h as $request) { if ($i > 0) { $this->assertSame($requests[$i], $request); } } }
/** * Get the response to the last request made by the Guzzle client * * @return Response */ protected function getLastResponse() { $lastRequest = $this->history->getLastRequest(); if (!$lastRequest) { return null; } return $lastRequest->getResponse(); }
public function testBrokenJsonResponse() { $client = new Client(); $mock = new MockPlugin(); $mock->addResponse(new Response(200, null, $this->tokenResponse[1])); $client->addSubscriber($mock); $history = new HistoryPlugin(); $history->setLimit(5); $client->addSubscriber($history); $guzzle3Client = new Guzzle3Client($client); $tokenRequest = new TokenRequest($guzzle3Client, $this->clientConfig[0]); $this->assertFalse($tokenRequest->withRefreshToken('refresh_123_456')); }
/** * @param $operation * @param array $parameters * @param bool $mockResponse * @return Response */ protected function getResponse($operation, array $parameters, $mockResponse = true, MeasurementProtocolClient $client = null, $statusCode = 200) { if (null === $client) { $client = $this->getServiceBuilder()->get('ga_measurement_protocol'); } if (true === $mockResponse) { $mock = new MockPlugin(array(new Response($statusCode)), true); $client->addSubscriber($mock); } $history = new HistoryPlugin(); $history->setLimit(3); $client->addSubscriber($history); $this->history = $history; $return = call_user_func(array($client, $operation), $parameters); return $return; }