/** @test */ public function it_requests_for_access_token_successfully() { $this->thereIsSuccessfullFacebookApiResponse(); $accessToken = $this->adapter->accessToken('correct-code'); $this->assertEquals('access-token', $accessToken); $this->assertThatRequestIsEqual($this->expectedSuccessfulAccessTokenRequest(), $this->history->getLastRequest()); }
public function testHarvest() { $this->commandTester->execute(array('command' => $this->getCommandName())); $deposits = $this->em->getRepository('AppBundle:Deposit')->findBy(array('state' => 'harvest-error')); $this->assertCount(1, $this->history); $this->assertEquals('HEAD', $this->history->getLastRequest()->getMethod()); $this->assertCount(1, $deposits); $this->assertContains('Deposit harvest failed.', $deposits[0]->getProcessingLog()); }
/** * @expectedException \EvdB\OpenExchangeRates\Exception\ResourceNotFound */ public function testJsonpCallbackPresence() { $exchange = $this->buildExchangeRateClient(null, $client = $this->buildClient()); $this->mockResponses($client, [new Response(200)]); $exchange->jsonp('latest', [], 'testMyCallback'); $this->assertEquals('testMyCallback', $this->history->getLastRequest()->getQuery()->get('callback')); //will throw expected exception $exchange->jsonp('invalid', [], 'myInvalidCallback'); }
protected function printLastRequestUrl() { $lastRequest = self::$history->getLastRequest(); if ($lastRequest) { $this->printDebug(sprintf('<comment>%s</comment>: <info>%s</info>', $lastRequest->getMethod(), $lastRequest->getUrl())); } else { $this->printDebug('No request was made.'); } }
public function testDeleteHeadersByEmptyValue() { $this->module->setHeader('xxx', 'yyyy'); $this->module->setHeader('xxx', ''); $this->module->amOnPage('/'); $this->assertFalse($this->history->getLastRequest()->hasHeader('xxx')); }
public function testCanGetAvailableModules() { // Create a mock subscriber and queue the response. $mock = new Mock([new Response(file_get_contents('./tests/mock/response-availablemodules.txt'))]); $this->client->getEmitter()->attach($mock); // Get available modules $this->wsclient->getAvailableModules(); // Get the last request $lastRequest = $this->history->getLastRequest(); $this->assertEquals('http://www.example.com/webservice.php?operation=listtypes&sessionName=18653fb863106084', $lastRequest->getUrl()); $this->assertEquals('GET', $lastRequest->getMethod()); $this->assertEmpty((string) $lastRequest->getBody()); // Detaching subscriber $this->client->getEmitter()->detach($mock); }
public function testRequestHeaders() { $request = $this->history->getLastRequest(); $this->assertEquals('GET', $request->getMethod()); $this->assertEquals('PkpPlnBot 1.0; http://pkp.sfu.ca', $request->getHeader('User-Agent')); }
public function testHeadersBySetHeader() { $this->module->setHeader('xxx', 'yyyy'); $this->module->amOnPage('/'); $this->assertTrue($this->history->getLastRequest()->hasHeader('xxx')); }
public function testDeleteListing() { $client = $this->createClient('delete_listing', $history = new History()); $response = $client->deleteListing(['listing_id' => '129242581']); $this->assertSame('DELETE', $history->getLastRequest()->getMethod()); $this->assertSame('https://api.discogs.com/marketplace/listings/129242581', $history->getLastRequest()->getUrl()); }
public function testGetImage() { $client = $this->createClient('get_inventory', $history = new History()); $response = $client->getImage(['filename' => 'R-5840514-1404162639-4473.jpeg']); $this->assertArrayHasKey('image', $response); $this->assertSame(37814, strlen($response['image'])); $this->assertInstanceOf('GuzzleHttp\\Stream\\Stream', $response['image']); $this->assertSame('GET', $history->getLastRequest()->getMethod()); $this->assertSame('http://api.discogs.com/images/R-5840514-1404162639-4473.jpeg', $history->getLastRequest()->getUrl()); }