Skip to content

Commit

Permalink
Change Issuer code type from int to string (#195)
Browse files Browse the repository at this point in the history
* Change Issuer code type from int to string

* Change type from int to string on issuer code class property

* Add change to changelog

* Change changelog text
  • Loading branch information
vinodsowdagar authored Sep 3, 2020
1 parent d568af8 commit a2e8437
Show file tree
Hide file tree
Showing 5 changed files with 16 additions and 14 deletions.
2 changes: 2 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
10 changes: 5 additions & 5 deletions src/Api/Issuers/Issuer.php
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ class Issuer
private $gatewayCode;

/**
* @var int
* @var string
*/
private $code;

Expand All @@ -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);
Expand Down Expand Up @@ -71,9 +71,9 @@ public function getGatewayCode(): string
}

/**
* @return int
* @return string
*/
public function getCode(): int
public function getCode(): string
{
return $this->code;
}
Expand Down
2 changes: 1 addition & 1 deletion src/Api/Issuers/IssuerListing.php
Original file line number Diff line number Diff line change
Expand Up @@ -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']);
}
}

Expand Down
6 changes: 3 additions & 3 deletions tests/Unit/Api/Issuers/IssuerListingTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -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());
}
}
10 changes: 5 additions & 5 deletions tests/Unit/Api/Issuers/IssuerTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -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');
}
}

0 comments on commit a2e8437

Please sign in to comment.