public function testSingleCallAgain() { $this->createBasicHandler(); $this->startBenchmark(); $this->gigya->accounts()->getAccountInfo(['uid' => 'some_uid']); $this->printBenchmark(__METHOD__, 1); }
public function testCredentialsAuthConstructor() { $this->guzzleClient->shouldReceive('__construct')->with(['handler' => $this->handlerStack])->once()->andReturn($this->guzzleClient); $response = new Response(200, [], TestFixtures::getFixture('account.getAccountInfo')); $this->guzzleClient->shouldReceive('get')->with('https://accounts.au1.gigya.com/accounts.getAccountInfo', ['cert' => 'some_cert.pem', 'auth' => 'credentials', 'verify' => $this->certPath, 'query' => []])->once()->andReturn($response); $gigyaResponse = m::mock('Graze\\Gigya\\Response\\ResponseInterface'); $this->factory->shouldReceive('getResponse')->with($response)->andReturn($gigyaResponse); $config = ['auth' => 'credentials', 'uidValidator' => false, 'factory' => $this->factory, 'guzzle' => ['handler' => $this->handlerStack], 'options' => ['cert' => 'some_cert.pem']]; $client = new Gigya('key', 'secret', Gigya::DC_AU, null, $config); static::assertSame($gigyaResponse, $client->accounts()->getAccountInfo()); }
public function testGigyaWillTriggerSubscriberOnlyWhenItIsAddedInARequest() { $handler = $this->setupHandler(); $client = new Gigya('key', 'secret', null, null, ['guzzle' => ['handler' => $handler]]); $client->accounts()->getAccountInfo(); $called = 0; $fn = function (callable $handler) use(&$called) { return function (RequestInterface $request, $options) use($handler, &$called) { $called++; return $handler($request, $options); }; }; $client->addHandler($fn); $client->accounts()->getAccountInfo(); $this->assertEquals(1, $called); $client->removeHandler($fn); $client->accounts()->getAccountInfo(); $this->assertEquals(1, $called); }
public function testSettingTheUserKeyWillPassItThroughToGuzzle() { $client = new Gigya('key', 'userSecret', Gigya::DC_EU, 'userKey'); $response = m::mock('GuzzleHttp\\Message\\ResponseInterface'); $response->shouldReceive('getBody')->andReturn(TestFixtures::getFixture('accounts.getAccountInfo')); $this->guzzleClient->shouldReceive('get')->with('https://accounts.eu1.gigya.com/accounts.getAccountInfo', ['query' => ['apiKey' => 'key', 'secret' => 'userSecret', 'userKey' => 'userKey'], 'cert' => $this->certPath])->andReturn($response); $gigyaResponse = m::mock('Graze\\Gigya\\Response\\ResponseInterface'); $this->factory->shouldReceive('getResponse')->with($response)->andReturn($gigyaResponse); $result = $client->accounts()->getAccountInfo([]); static::assertSame($gigyaResponse, $result); }