| @@ 101-144 (lines=44) @@ | ||
| 98 | static::assertInstanceOf(Gigya::class, $client); |
|
| 99 | } |
|
| 100 | ||
| 101 | public function testConstructorConfig() |
|
| 102 | { |
|
| 103 | $this->guzzleClient->shouldReceive('__construct') |
|
| 104 | ->once() |
|
| 105 | ->with( |
|
| 106 | [ |
|
| 107 | 'handler' => $this->handlerStack, |
|
| 108 | ] |
|
| 109 | ) |
|
| 110 | ->andReturn($this->guzzleClient); |
|
| 111 | ||
| 112 | $response = new Response(200, [], TestFixtures::getFixture('account.getAccountInfo')); |
|
| 113 | ||
| 114 | $this->guzzleClient->shouldReceive('post') |
|
| 115 | ->with( |
|
| 116 | 'https://accounts.au1.gigya.com/accounts.getAccountInfo', |
|
| 117 | [ |
|
| 118 | 'cert' => 'some_cert.pem', |
|
| 119 | 'auth' => 'oauth', |
|
| 120 | 'verify' => $this->certPath, |
|
| 121 | 'form_params' => [], |
|
| 122 | ] |
|
| 123 | ) |
|
| 124 | ->andReturn($response); |
|
| 125 | ||
| 126 | $gigyaResponse = m::mock('Graze\Gigya\Response\ResponseInterface'); |
|
| 127 | ||
| 128 | $this->factory->shouldReceive('getResponse') |
|
| 129 | ->with($response) |
|
| 130 | ->andReturn($gigyaResponse); |
|
| 131 | ||
| 132 | $config = [ |
|
| 133 | 'auth' => 'oauth', |
|
| 134 | 'uidValidator' => false, |
|
| 135 | 'factory' => $this->factory, |
|
| 136 | 'guzzle' => [ |
|
| 137 | 'handler' => $this->handlerStack, |
|
| 138 | ], |
|
| 139 | 'options' => [ |
|
| 140 | 'cert' => 'some_cert.pem', |
|
| 141 | ], |
|
| 142 | ]; |
|
| 143 | $client = new Gigya('key', 'secret', Gigya::DC_AU, null, $config); |
|
| 144 | ||
| 145 | static::assertSame($gigyaResponse, $client->accounts()->getAccountInfo()); |
|
| 146 | } |
|
| 147 | ||
| @@ 148-191 (lines=44) @@ | ||
| 145 | static::assertSame($gigyaResponse, $client->accounts()->getAccountInfo()); |
|
| 146 | } |
|
| 147 | ||
| 148 | public function testOAuth2AuthConstructor() |
|
| 149 | { |
|
| 150 | $this->guzzleClient->shouldReceive('__construct') |
|
| 151 | ->once() |
|
| 152 | ->with( |
|
| 153 | [ |
|
| 154 | 'handler' => $this->handlerStack, |
|
| 155 | ] |
|
| 156 | ) |
|
| 157 | ->andReturn($this->guzzleClient); |
|
| 158 | ||
| 159 | $response = new Response(200, [], TestFixtures::getFixture('account.getAccountInfo')); |
|
| 160 | ||
| 161 | $this->guzzleClient->shouldReceive('post') |
|
| 162 | ->with( |
|
| 163 | 'https://accounts.au1.gigya.com/accounts.getAccountInfo', |
|
| 164 | [ |
|
| 165 | 'cert' => 'some_cert.pem', |
|
| 166 | 'auth' => 'gigya-oauth2', |
|
| 167 | 'verify' => $this->certPath, |
|
| 168 | 'form_params' => [], |
|
| 169 | ] |
|
| 170 | ) |
|
| 171 | ->andReturn($response); |
|
| 172 | ||
| 173 | $gigyaResponse = m::mock('Graze\Gigya\Response\ResponseInterface'); |
|
| 174 | ||
| 175 | $this->factory->shouldReceive('getResponse') |
|
| 176 | ->with($response) |
|
| 177 | ->andReturn($gigyaResponse); |
|
| 178 | ||
| 179 | $config = [ |
|
| 180 | 'auth' => 'gigya-oauth2', |
|
| 181 | 'uidValidator' => false, |
|
| 182 | 'factory' => $this->factory, |
|
| 183 | 'guzzle' => [ |
|
| 184 | 'handler' => $this->handlerStack, |
|
| 185 | ], |
|
| 186 | 'options' => [ |
|
| 187 | 'cert' => 'some_cert.pem', |
|
| 188 | ], |
|
| 189 | ]; |
|
| 190 | $client = new Gigya('key', 'secret', Gigya::DC_AU, null, $config); |
|
| 191 | ||
| 192 | static::assertSame($gigyaResponse, $client->accounts()->getAccountInfo()); |
|
| 193 | } |
|
| 194 | ||
| @@ 195-240 (lines=46) @@ | ||
| 192 | static::assertSame($gigyaResponse, $client->accounts()->getAccountInfo()); |
|
| 193 | } |
|
| 194 | ||
| 195 | public function testCredentialsAuthConstructor() |
|
| 196 | { |
|
| 197 | $this->guzzleClient->shouldReceive('__construct') |
|
| 198 | ->with( |
|
| 199 | [ |
|
| 200 | 'handler' => $this->handlerStack, |
|
| 201 | ] |
|
| 202 | ) |
|
| 203 | ->once() |
|
| 204 | ->andReturn($this->guzzleClient); |
|
| 205 | ||
| 206 | $response = new Response(200, [], TestFixtures::getFixture('account.getAccountInfo')); |
|
| 207 | ||
| 208 | $this->guzzleClient->shouldReceive('post') |
|
| 209 | ->with( |
|
| 210 | 'https://accounts.au1.gigya.com/accounts.getAccountInfo', |
|
| 211 | [ |
|
| 212 | 'cert' => 'some_cert.pem', |
|
| 213 | 'auth' => 'credentials', |
|
| 214 | 'verify' => $this->certPath, |
|
| 215 | 'form_params' => [], |
|
| 216 | ] |
|
| 217 | ) |
|
| 218 | ->once() |
|
| 219 | ->andReturn($response); |
|
| 220 | ||
| 221 | $gigyaResponse = m::mock('Graze\Gigya\Response\ResponseInterface'); |
|
| 222 | ||
| 223 | $this->factory->shouldReceive('getResponse') |
|
| 224 | ->with($response) |
|
| 225 | ->andReturn($gigyaResponse); |
|
| 226 | ||
| 227 | $config = [ |
|
| 228 | 'auth' => 'credentials', |
|
| 229 | 'uidValidator' => false, |
|
| 230 | 'factory' => $this->factory, |
|
| 231 | 'guzzle' => [ |
|
| 232 | 'handler' => $this->handlerStack, |
|
| 233 | ], |
|
| 234 | 'options' => [ |
|
| 235 | 'cert' => 'some_cert.pem', |
|
| 236 | ], |
|
| 237 | ]; |
|
| 238 | $client = new Gigya('key', 'secret', Gigya::DC_AU, null, $config); |
|
| 239 | ||
| 240 | static::assertSame($gigyaResponse, $client->accounts()->getAccountInfo()); |
|
| 241 | } |
|
| 242 | ||
| 243 | public function testSettingKeyAndSecretWillPassToGuzzleClient() |
|