Skip to content

Commit

Permalink
Putting setters back
Browse files Browse the repository at this point in the history
  • Loading branch information
ShortlyMAB committed Oct 24, 2019
1 parent 9a4e730 commit 60b2cdc
Show file tree
Hide file tree
Showing 2 changed files with 33 additions and 15 deletions.
36 changes: 29 additions & 7 deletions src/Provider/Mollie.php
Original file line number Diff line number Diff line change
Expand Up @@ -66,25 +66,47 @@ class Mollie extends AbstractProvider
/**
* @var string
*/
private $mollieApiUrl;
private $mollieApiUrl = self::MOLLIE_API_URL;

/**
* @var string
*/
private $mollieWebUrl;
private $mollieWebUrl = self::MOLLIE_WEB_URL;

public function __construct(array $options = [], array $collaborators = [])
{
parent::__construct($options, $collaborators);

if (isset($options["clientId"]) && strpos($options["clientId"], self::CLIENT_ID_PREFIX) !== 0) {
throw new \DomainException("Mollie needs the client ID to be prefixed with " . self::CLIENT_ID_PREFIX . ".");
}
}

$this->mollieApiUrl = (isset($options['mollieApiUrl']) ? $options['mollieApiUrl'] : null) ?: self::MOLLIE_API_URL;
$this->mollieWebUrl = (isset($options['mollieWebUrl']) ? $options['mollieWebUrl'] : null) ?: self::MOLLIE_WEB_URL;
unset($options['mollieApiUrl'], $options['mollieWebUrl']);
/**
* Define Mollie api URL
*
* @param string $url
* @return Mollie
*/
public function setMollieApiUrl ($url)
{
$this->mollieApiUrl = $url;

parent::__construct($options, $collaborators);
}
return $this;
}

/**
* Define Mollie web URL
*
* @param string $url
* @return Mollie
*/
public function setMollieWebUrl ($url)
{
$this->mollieWebUrl = $url;

return $this;
}

/**
* Returns the base URL for authorizing a client.
Expand Down
12 changes: 4 additions & 8 deletions tests/src/Provider/MollieTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -217,20 +217,16 @@ public function testUserData()

public function testWhenDefiningADifferentMollieApiUrlThenUseThisOnApiCalls()
{
$options = array_merge(['mollieApiUrl' => 'https://api.mollie.nl'], self::OPTIONS);
$this->provider->setMollieApiUrl('https://api.mollie.nl');

$provider = new Mollie($options);

$this->assertEquals('https://api.mollie.nl/oauth2/tokens', $provider->getBaseAccessTokenUrl([]));
$this->assertEquals('https://api.mollie.nl/oauth2/tokens', $this->provider->getBaseAccessTokenUrl([]));
}

public function testWhenDefiningADifferentMollieWebUrlThenUseThisForAuthorize()
{
$options = array_merge(['mollieWebUrl' => 'https://www.mollie.nl'], self::OPTIONS);

$provider = new Mollie($options);
$this->provider->setMollieWebUrl('https://www.mollie.nl');

list($url) = explode('?', $provider->getAuthorizationUrl());
list($url) = explode('?', $this->provider->getAuthorizationUrl());
$this->assertEquals('https://www.mollie.nl/oauth2/authorize', $url);
}
}

0 comments on commit 60b2cdc

Please sign in to comment.