-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
c31469d
commit 6fabbea
Showing
14 changed files
with
257 additions
and
47 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
<?php | ||
|
||
declare(strict_types=1); | ||
|
||
namespace Calculator; | ||
|
||
use DummyGenerator\Core\Calculator\EanCalculator; | ||
use PHPUnit\Framework\TestCase; | ||
|
||
class EanCalculatorTest extends TestCase | ||
{ | ||
private const string EAN8 = '96385074'; | ||
private const string EAN13 = '5901234123457'; | ||
|
||
public function testChecksum(): void | ||
{ | ||
$calculator = new EanCalculator; | ||
|
||
self::assertEquals(4, $calculator->checksum('9638507')); | ||
self::assertEquals(7, $calculator->checksum('590123412345')); | ||
} | ||
|
||
public function testIsValid(): void | ||
{ | ||
$calculator = new EanCalculator; | ||
|
||
self::assertTrue($calculator->isValid(self::EAN8)); | ||
self::assertTrue($calculator->isValid(self::EAN13)); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
<?php | ||
|
||
declare(strict_types=1); | ||
|
||
namespace Calculator; | ||
|
||
use DummyGenerator\Core\Calculator\IbanCalculator; | ||
use PHPUnit\Framework\TestCase; | ||
|
||
class IbanCalculatorTest extends TestCase | ||
{ | ||
private const string IBAN = 'IE64IRCE92050112345678'; | ||
|
||
public function testChecksum(): void | ||
{ | ||
$calculator = new IbanCalculator(); | ||
|
||
self::assertEquals(64, $calculator->checksum('IE64IRCE92050112345678')); | ||
} | ||
|
||
public function testIsValid(): void | ||
{ | ||
$calculator = new IbanCalculator(); | ||
|
||
self::assertTrue($calculator->isValid(self::IBAN)); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
<?php | ||
|
||
declare(strict_types=1); | ||
|
||
namespace Calculator; | ||
|
||
use DummyGenerator\Core\Calculator\IsbnCalculator; | ||
use PHPUnit\Framework\TestCase; | ||
|
||
class IsbnCalculatorTest extends TestCase | ||
{ | ||
private const string ISBN10 = '2123456802'; | ||
// private const string ISBN13 = '9782123456803'; | ||
|
||
public function testChecksum(): void | ||
{ | ||
$calculator = new IsbnCalculator(); | ||
|
||
self::assertEquals(2, $calculator->checksum('212345680')); | ||
} | ||
|
||
public function testIsValid(): void | ||
{ | ||
$calculator = new IsbnCalculator(); | ||
|
||
self::assertTrue($calculator->isValid(self::ISBN10)); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
<?php | ||
|
||
declare(strict_types=1); | ||
|
||
namespace Calculator; | ||
|
||
use DummyGenerator\Core\Calculator\LuhnCalculator; | ||
use PHPUnit\Framework\TestCase; | ||
|
||
class LuhnCalculatorTest extends TestCase | ||
{ | ||
private const string LUHN = '17893729974'; | ||
|
||
public function testIsValid(): void | ||
{ | ||
$calculator = new LuhnCalculator(); | ||
|
||
self::assertTrue($calculator->isValid(self::LUHN)); | ||
} | ||
|
||
public function testComputeCheckDigit(): void | ||
{ | ||
$calculator = new LuhnCalculator(); | ||
|
||
self::assertEquals('4', $calculator->computeCheckDigit('1789372997')); | ||
} | ||
|
||
public function testGenerateLuhnNumber(): void | ||
{ | ||
$calculator = new LuhnCalculator(); | ||
|
||
self::assertEquals(self::LUHN, $calculator->generateLuhnNumber('1789372997')); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.