diff --git a/CHANGELOG.md b/CHANGELOG.md index 8906c49..b59dc38 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -5,6 +5,8 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/), and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html). ## [Unreleased] +### Fixed +- Fix bug where issuers wouldn't be able to load because of wrong issuer code type (int instead of string) ## [3.0.1] - 2020-09-02 ### Fixed diff --git a/src/Api/Issuers/Issuer.php b/src/Api/Issuers/Issuer.php index 6fac171..ff04ed1 100644 --- a/src/Api/Issuers/Issuer.php +++ b/src/Api/Issuers/Issuer.php @@ -20,7 +20,7 @@ class Issuer private $gatewayCode; /** - * @var int + * @var string */ private $code; @@ -37,10 +37,10 @@ class Issuer /** * Issuer constructor. * @param string $gatewayCode - * @param int $code + * @param string $code * @param string $description */ - public function __construct(string $gatewayCode, int $code, string $description) + public function __construct(string $gatewayCode, string $code, string $description) { $this->validateGatewayCode($gatewayCode); $this->gatewayCode = strtoupper($gatewayCode); @@ -71,9 +71,9 @@ public function getGatewayCode(): string } /** - * @return int + * @return string */ - public function getCode(): int + public function getCode(): string { return $this->code; } diff --git a/src/Api/Issuers/IssuerListing.php b/src/Api/Issuers/IssuerListing.php index 99a9318..e6c508b 100644 --- a/src/Api/Issuers/IssuerListing.php +++ b/src/Api/Issuers/IssuerListing.php @@ -22,7 +22,7 @@ class IssuerListing public function __construct(string $gatewayCode, array $data) { foreach ($data as $issuerData) { - $this->issuers[] = new Issuer($gatewayCode, (int)$issuerData['code'], $issuerData['description']); + $this->issuers[] = new Issuer($gatewayCode, $issuerData['code'], $issuerData['description']); } } diff --git a/tests/Unit/Api/Issuers/IssuerListingTest.php b/tests/Unit/Api/Issuers/IssuerListingTest.php index bf23a70..6668569 100644 --- a/tests/Unit/Api/Issuers/IssuerListingTest.php +++ b/tests/Unit/Api/Issuers/IssuerListingTest.php @@ -16,12 +16,12 @@ class IssuerListingTest extends TestCase */ public function testGetIssuers() { - $issuerListing = new IssuerListing('ideal', [['code' => 1234, 'description' => 'bar']]); + $issuerListing = new IssuerListing('ideal', [['code' => '0021', 'description' => 'bar']]); $issuers = $issuerListing->getIssuers(); - $this->assertEquals(1, count($issuers)); + $this->assertCount(1, $issuers); $issuer = array_shift($issuers); - $this->assertEquals(1234, $issuer->getCode()); + $this->assertEquals('0021', $issuer->getCode()); $this->assertEquals('bar', $issuer->getDescription()); } } diff --git a/tests/Unit/Api/Issuers/IssuerTest.php b/tests/Unit/Api/Issuers/IssuerTest.php index 065b0d9..6716e0e 100644 --- a/tests/Unit/Api/Issuers/IssuerTest.php +++ b/tests/Unit/Api/Issuers/IssuerTest.php @@ -17,21 +17,21 @@ class IssuerTest extends TestCase */ public function testNormalInitialization() { - $issuer = new Issuer('ideal', 1234, 'bar'); + $issuer = new Issuer('ideal', '0021', 'bar'); $this->assertEquals('IDEAL', $issuer->getGatewayCode()); - $this->assertEquals(1234, $issuer->getCode()); + $this->assertEquals('0021', $issuer->getCode()); $this->assertEquals('bar', $issuer->getDescription()); - $issuer = new Issuer('IDEAL', 1234, 'bar'); + $issuer = new Issuer('IDEAL', '0021', 'bar'); $this->assertEquals('IDEAL', $issuer->getGatewayCode()); } /** * Test if initialization fails if invalid gateway code is used */ - public function testInitializationWithWrongGatewayCode() + public function testInitializationWithInvalidGatewayCode() { $this->expectException(InvalidArgumentException::class); - new Issuer('wrong', 1234, 'foobar'); + new Issuer('wrong', '0021', 'foobar'); } }