public function testFactoryAddsPrivateTokenPluginToHttpClient()
 {
     $client = GuzzleClientFactory::createClient(['base_url' => 'https://example.com/gitlab', 'api_token' => 'QVy1PB7sTxfy4pqfZM1U']);
     $emitter = $client->getHttpClient()->getEmitter();
     $this->assertTrue($emitter->hasListeners('before'), 'The factory method should add the PrivateTokenPlugin listener automatically');
     $listeners = $emitter->listeners('before');
     foreach ($listeners as $listener) {
         $this->assertArrayHasKey(0, $listener);
         if ($listener[0] instanceof PrivateTokenPlugin) {
             return;
         }
     }
     $this->fail('Expected the guzzle client to have the ' . PrivateTokenPlugin::class);
 }
Пример #2
0
 /**
  * Factory method to create a fully configured GitlabClient.
  * @param array $config
  * @return GitlabGuzzleClient
  */
 public static function factory(array $config)
 {
     return GuzzleClientFactory::createClient($config);
 }