diff --git a/src/Wrappers/MollieApiWrapper.php b/src/Wrappers/MollieApiWrapper.php index f94efdd..be9795d 100644 --- a/src/Wrappers/MollieApiWrapper.php +++ b/src/Wrappers/MollieApiWrapper.php @@ -64,7 +64,11 @@ public function __construct(Repository $config, MollieApiClient $client) $this->config = $config; $this->client = $client; - $this->setApiKey($this->config->get('mollie.key')); + $key = $this->config->get('mollie.key'); + + if(! empty($key)) { + $this->setApiKey($key); + } } /** diff --git a/tests/Wrappers/MollieApiWrapperTest.php b/tests/Wrappers/MollieApiWrapperTest.php index e85dc3a..e838adf 100644 --- a/tests/Wrappers/MollieApiWrapperTest.php +++ b/tests/Wrappers/MollieApiWrapperTest.php @@ -85,6 +85,15 @@ public function testSetBadApiKey() $wrapper->setApiKey('live_'); } + public function testDoesNotSetKeyWhenEmpty() + { + config(['mollie.key' => '']); + $this->assertEmpty($this->app['config']['mollie']['key']); + $this->api->expects($this->never())->method('setApiKey'); + + $wrapper = new MollieApiWrapper($this->app['config'], $this->api); + } + public function testSetGoodToken() { $this->api->expects($this->once())->method('setAccessToken')->with('access_xxx');