Skip to content

Commit

Permalink
Removed unused entity, and ledger tests (#14)
Browse files Browse the repository at this point in the history
* Removed unused entity, and ledger tests
* Ledger status test
* ArrayResponse tests
  • Loading branch information
levelfivehub committed Jul 24, 2019
1 parent 8aed424 commit a79065b
Show file tree
Hide file tree
Showing 7 changed files with 80 additions and 155 deletions.
36 changes: 0 additions & 36 deletions src/Entity/Customer/GetLedger.php
Expand Up @@ -94,49 +94,31 @@ public function __construct($response)
parent::__construct($response);
}

/**
* @return string
*/
public function getIban():? string
{
return $this->iban;
}

/**
* @return string
*/
public function getSortCode():? string
{
return $this->sortCode;
}

/**
* @return string
*/
public function getAccountNumber():? string
{
return $this->accountNumber;
}

/**
* @return string
*/
public function getBicSwift():? string
{
return $this->bicSwift;
}

/**
* @return string
*/
public function getCurrentBalance():? string
{
return $this->currentBalance;
}

/**
* @return string
*/
public function getStatus():? string
{
return $this->status;
Expand All @@ -147,49 +129,31 @@ public function isLedgerStatusOk(): bool
return ($this->status === 'ledger-status-ok');
}

/**
* @return float
*/
public function getAmount(): float
{
return $this->amount;
}

/**
* @return string
*/
public function getAssetClass(): string
{
return $this->assetClass;
}

/**
* @return string
*/
public function getAssetType(): string
{
return $this->assetType;
}

/**
* @return string
*/
public function getCreatedAt(): string
{
return $this->createdAt;
}

/**
* @return string
*/
public function getHolderId(): string
{
return $this->holderId;
}

/**
* @return string
*/
public function getLastModifiedAt(): string
{
return $this->lastModifiedAt;
Expand Down
113 changes: 0 additions & 113 deletions src/Entity/Customer/GetLedgers.php

This file was deleted.

5 changes: 0 additions & 5 deletions src/Entity/Customer/Ledger.php
Expand Up @@ -7,7 +7,6 @@

/**
* Class Ledger
* @package Railsbank\Entity\Customer\Ledger
*/
class Ledger extends Entity implements EntityInterface
{
Expand All @@ -16,10 +15,6 @@ class Ledger extends Entity implements EntityInterface
*/
private $ledgerId;

/**
* Person constructor.
* @param mixed $response
*/
public function __construct($response)
{
$response = new ArrayResponse($response);
Expand Down
7 changes: 6 additions & 1 deletion src/Helper/ArrayResponse.php
Expand Up @@ -6,7 +6,7 @@ class ArrayResponse
/**
* @var array
*/
private $apiResponse;
private $apiResponse = [];

/**
* ArrayResponse constructor.
Expand Down Expand Up @@ -40,4 +40,9 @@ public function offsetGet($offset)
{
return $this->apiResponse[$offset] ?? null;
}

public function getArray() : array
{
return $this->apiResponse;
}
}
42 changes: 42 additions & 0 deletions tests/Entity/Customer/GetLedgerTest.php
@@ -0,0 +1,42 @@
<?php

namespace Test\Entity\Customer;

use PHPUnit\Framework\TestCase;
use Railsbank\Entity\Customer\GetLedger;

class GetLedgerTest extends TestCase
{
public function testGetLedger()
{
$response = [
'iban' => 'GB1100001111GB',
'uk_sort_code' => '10-10-11',
'bic_swift' => '10023',
'uk_account_number' => '10200111',
'amount' => '103032.22',
'asset_class' => 'UKGBP',
'asset_type' => 'currency',
'created_at' => '2019-01-01',
'holder_id' => '1234',
'last_modified_at' => '2019-03-22',
'ledger_status' => 'ledger-status-ok',
];

$entity = new GetLedger($response);

self::assertEquals('GB1100001111GB', $entity->getIban());
self::assertEquals('10-10-11', $entity->getSortCode());
self::assertEquals('10023', $entity->getBicSwift());
self::assertEquals('10200111', $entity->getAccountNumber());
self::assertEquals('103032.22', $entity->getAmount());
self::assertEquals('UKGBP', $entity->getAssetClass());
self::assertEquals('currency', $entity->getAssetType());
self::assertEquals('2019-01-01', $entity->getCreatedAt());
self::assertEquals('1234', $entity->getHolderId());
self::assertEquals('103032.22', $entity->getCurrentBalance());
self::assertEquals('ledger-status-ok', $entity->getStatus());
self::assertEquals('2019-03-22', $entity->getLastModifiedAt());
self::assertTrue($entity->isLedgerStatusOk());
}
}
20 changes: 20 additions & 0 deletions tests/Entity/Customer/LedgerTest.php
@@ -0,0 +1,20 @@
<?php

namespace Test\Entity\Customer\EndUsers;

use PHPUnit\Framework\TestCase;
use Railsbank\Entity\Customer\Ledger;

class LedgerTest extends TestCase
{
public function testLedger()
{
$response = [
'ledger_id' => '1234',
];

$entity = new Ledger($response);

self::assertEquals('1234', $entity->getLedgerId());
}
}
12 changes: 12 additions & 0 deletions tests/Helper/ArrayResponseTest.php
Expand Up @@ -31,4 +31,16 @@ public function testArrayExists()
self::assertEquals('hello', $this->helper->offsetGet('world'));
}

public function testArrayNoOffset()
{
$this->helper->offsetSet(null, '123');

self::assertEquals(
[
'123',
'hello' => 'world'
],
$this->helper->getArray()
);
}
}

0 comments on commit a79065b

Please sign in to comment.