Skip to content

Commit

Permalink
fix: include guzzle configuration when additionalConfigKeys is defi…
Browse files Browse the repository at this point in the history
…ned in provider
  • Loading branch information
kidager committed Feb 15, 2024
1 parent 35e15ed commit d2b9ee1
Show file tree
Hide file tree
Showing 2 changed files with 36 additions and 1 deletion.
4 changes: 3 additions & 1 deletion src/Helpers/ConfigRetriever.php
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,9 @@ public function fromServices($providerName, array $additionalConfigKeys = [])
$this->providerName = $providerName;
$this->getConfigFromServicesArray($providerName);

$this->additionalConfigKeys = $additionalConfigKeys = array_unique($additionalConfigKeys + ['guzzle']);
$this->additionalConfigKeys = $additionalConfigKeys = array_unique(
array_merge($additionalConfigKeys, ['guzzle']),
);

return new Config(
$this->getFromServices('client_id'),
Expand Down
33 changes: 33 additions & 0 deletions tests/ConfigRetrieverTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -76,6 +76,39 @@ public function it_retrieves_a_config_from_the_services(): void
$this->assertSame($uri, $result['redirect']);
$this->assertSame($additionalConfigItem, $result['additional']);
}

/**
* @test
*/
public function it_retrieves_a_config_from_the_services_with_guzzle(): void
{
$providerName = 'test';
$key = 'key';
$secret = 'secret';
$uri = 'uri';
$additionalConfigItem = 'test';
$config = [
'client_id' => $key,
'client_secret' => $secret,
'redirect' => $uri,
'additional' => $additionalConfigItem,
'guzzle' => ['verify' => false],
];
self::$functions
->shouldReceive('config')
->with("services.{$providerName}")
->once()
->andReturn($config);
$configRetriever = new ConfigRetriever();

$result = $configRetriever->fromServices($providerName, ['additional'])->get();

$this->assertSame($key, $result['client_id']);
$this->assertSame($secret, $result['client_secret']);
$this->assertSame($uri, $result['redirect']);
$this->assertSame($additionalConfigItem, $result['additional']);
$this->assertSame(['verify' => false], $result['guzzle']);
}
}

namespace SocialiteProviders\Manager\Helpers;
Expand Down

0 comments on commit d2b9ee1

Please sign in to comment.