Skip to content

Commit

Permalink
Merge pull request #18 from RikudouSage/tests/fix-formatting
Browse files Browse the repository at this point in the history
apply cs fixer to tests
  • Loading branch information
RikudouSage committed Dec 21, 2018
2 parents 03a82f2 + d8b15fa commit 8ec3aac
Show file tree
Hide file tree
Showing 8 changed files with 154 additions and 177 deletions.
76 changes: 38 additions & 38 deletions tests/CzechIbanAdapterTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -7,58 +7,57 @@

class CzechIbanAdapterTest extends TestCase
{

public function testAccountsWithoutPrefix()
{
$accounts = array(
"CZ55 3030 0000 0013 2509 0010" => [
"acc" => "1325090010",
"bank" => "3030",
$accounts = [
'CZ55 3030 0000 0013 2509 0010' => [
'acc' => '1325090010',
'bank' => '3030',
],
"CZ36 3030 0000 0013 2509 0061" => [
"acc" => "1325090061",
"bank" => "3030",
'CZ36 3030 0000 0013 2509 0061' => [
'acc' => '1325090061',
'bank' => '3030',
],
"CZ91 0300 0000 0002 8111 5217" => [
"acc" => "281115217",
"bank" => "0300",
'CZ91 0300 0000 0002 8111 5217' => [
'acc' => '281115217',
'bank' => '0300',
],
"CZ52 0300 0000 0000 0398 3815" => [
"acc" => "3983815",
"bank" => "0300",
'CZ52 0300 0000 0000 0398 3815' => [
'acc' => '3983815',
'bank' => '0300',
],
"CZ13 2700 0000 0005 0011 4004" => [
"acc" => "500114004",
"bank" => "2700",
'CZ13 2700 0000 0005 0011 4004' => [
'acc' => '500114004',
'bank' => '2700',
],
);
];

foreach ($accounts as $iban => $accountData) {
$iban = str_replace(" ", "", $iban);
$this->assertEquals($iban, $this->getIban($accountData["acc"], $accountData["bank"])->asString());
$this->assertEquals($iban, strval($this->getIban($accountData["acc"], $accountData["bank"])));
$iban = str_replace(' ', '', $iban);
$this->assertEquals($iban, $this->getIban($accountData['acc'], $accountData['bank'])->asString());
$this->assertEquals($iban, strval($this->getIban($accountData['acc'], $accountData['bank'])));
}
}

public function testAccountsWithPrefix()
{
$accounts = array(
"CZ03 0710 0010 1100 1792 9051" => [
"acc" => "17929051",
"bank" => "0710",
"prefix" => "1011"
$accounts = [
'CZ03 0710 0010 1100 1792 9051' => [
'acc' => '17929051',
'bank' => '0710',
'prefix' => '1011',
],
'CZ47 0710 0210 1200 2792 4051' => [
'acc' => '27924051',
'bank' => '0710',
'prefix' => '21012',
],
"CZ47 0710 0210 1200 2792 4051" => [
"acc" => "27924051",
"bank" => "0710",
"prefix" => "21012"
]
);
];

foreach ($accounts as $iban => $accountData) {
$iban = str_replace(" ", "", $iban);
$this->assertEquals($iban, $this->getIban($accountData["acc"], $accountData["bank"], $accountData["prefix"])->asString());
$this->assertEquals($iban, strval($this->getIban($accountData["acc"], $accountData["bank"], $accountData["prefix"])));
$iban = str_replace(' ', '', $iban);
$this->assertEquals($iban, $this->getIban($accountData['acc'], $accountData['bank'], $accountData['prefix'])->asString());
$this->assertEquals($iban, strval($this->getIban($accountData['acc'], $accountData['bank'], $accountData['prefix'])));
}
}

Expand All @@ -68,18 +67,19 @@ public function testGetValidator()
}

/**
* @param string|int $account
* @param string|int $bankCode
* @param string|int $account
* @param string|int $bankCode
* @param string|int|null $prefix
*
* @return CzechIbanAdapter
*/
private function getIban($account, $bankCode, $prefix = NULL): CzechIbanAdapter
private function getIban($account, $bankCode, $prefix = null): CzechIbanAdapter
{
if (!is_null($prefix)) {
$account = "{$prefix}-{$account}";
}
$ibanAdapter = new CzechIbanAdapter($account, $bankCode);

return $ibanAdapter;
}
}
45 changes: 22 additions & 23 deletions tests/CzechIbanValidatorTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -7,61 +7,60 @@

class CzechIbanValidatorTest extends TestCase
{

public function testIsValid()
{
foreach ($this->getAccounts() as $account) {
$this->assertEquals($account["valid"], (new CzechIbanValidator(...$account["account"]))->isValid());
$this->assertEquals($account['valid'], (new CzechIbanValidator(...$account['account']))->isValid());
}
}

private function getAccounts()
{
return [
[
"account" => [1325090010, 3030],
"valid" => true
'account' => [1325090010, 3030],
'valid' => true,
],
[
"account" => [1325090053, 3030],
"valid" => true
'account' => [1325090053, 3030],
'valid' => true,
],
[
"account" => [281115217, "0300"],
"valid" => true
'account' => [281115217, '0300'],
'valid' => true,
],
[
"account" => [500114004, 2700],
"valid" => true
'account' => [500114004, 2700],
'valid' => true,
],
[
"account" => ["1011-17929051", "0710"],
"valid" => true
'account' => ['1011-17929051', '0710'],
'valid' => true,
],
[
"account" => ["21012-27924051", "0710"],
"valid" => true
'account' => ['21012-27924051', '0710'],
'valid' => true,
],
[
// random invalid account
"account" => [123456, 1234],
"valid" => false
'account' => [123456, 1234],
'valid' => false,
],
[
// invalid prefix, valid account
"account" => ["1-1325090010", 3030],
"valid" => false
'account' => ['1-1325090010', 3030],
'valid' => false,
],
[
// too long prefix, valid account
"account" => ["1234567-1325090010", 3030],
"valid" => false
'account' => ['1234567-1325090010', 3030],
'valid' => false,
],
[
// too long account
"account" => [13250900101, 3030],
"valid" => false
]
'account' => [13250900101, 3030],
'valid' => false,
],
];
}
}
8 changes: 3 additions & 5 deletions tests/Data/ConstantsClass.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,6 @@

class ConstantsClass
{

const NAME1 = "value1";
const NAME2 = "value2";

}
const NAME1 = 'value1';
const NAME2 = 'value2';
}
27 changes: 13 additions & 14 deletions tests/GenericIbanValidatorTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -8,40 +8,39 @@

class GenericIbanValidatorTest extends TestCase
{

public function testIsValid()
{
foreach ($this->getIbans() as $iban) {
$this->assertEquals($iban["valid"], (new GenericIbanValidator($iban["iban"]))->isValid());
$this->assertEquals($iban['valid'], (new GenericIbanValidator($iban['iban']))->isValid());
}
}

private function getIbans()
{
return [
[
"iban" => new IBAN("CZ5530300000001325090010"),
"valid" => true
'iban' => new IBAN('CZ5530300000001325090010'),
'valid' => true,
],
[
"iban" => new IBAN("CZ5530300000001325090011"),
"valid" => false
'iban' => new IBAN('CZ5530300000001325090011'),
'valid' => false,
],
[
"iban" => new IBAN("CZ5530300000001325090012"),
"valid" => false
'iban' => new IBAN('CZ5530300000001325090012'),
'valid' => false,
],
[
"iban" => new IBAN("CZ1327000000000500114004"),
"valid" => true
'iban' => new IBAN('CZ1327000000000500114004'),
'valid' => true,
],
[
"iban" => new IBAN("CZ1327000000000500114005"),
"valid" => false
'iban' => new IBAN('CZ1327000000000500114005'),
'valid' => false,
],
[
"iban" => new IBAN("CZ0307100010110017929051"),
"valid" => true
'iban' => new IBAN('CZ0307100010110017929051'),
'valid' => true,
],
];
}
Expand Down
5 changes: 2 additions & 3 deletions tests/IBANTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
* Created by PhpStorm.
* User: root
* Date: 15.12.18
* Time: 2:11
* Time: 2:11.
*/

namespace rikudou\EuQrPayment\Tests;
Expand All @@ -13,7 +13,6 @@

class IBANTest extends TestCase
{

public function testGetIban()
{
$iban = new IBAN($this->getIbanString());
Expand All @@ -33,6 +32,6 @@ public function testGetValidator()

private function getIbanString(): string
{
return "CZ5530300000001325090010";
return 'CZ5530300000001325090010';
}
}
Loading

0 comments on commit 8ec3aac

Please sign in to comment.