1
|
|
|
<?php |
2
|
|
|
declare(strict_types=1); |
3
|
|
|
namespace Thunder\Currenz\Tests; |
4
|
|
|
|
5
|
|
|
use PHPUnit\Framework\TestCase; |
6
|
|
|
use Thunder\Currenz\Currency; |
7
|
|
|
|
8
|
|
|
final class CurrencyTest extends TestCase |
9
|
|
|
{ |
10
|
|
|
use TestTrait; |
11
|
|
|
|
12
|
|
|
public function testCurrency() |
13
|
|
|
{ |
14
|
|
|
$this->assertCurrency(new Currency('NAME', 'COD', 2, ['RANDOM'], '128'), 'COD', 'NAME', ['RANDOM'], 2, '128'); |
15
|
|
|
} |
16
|
|
|
|
17
|
|
|
public function testExceptionWhenEmptyName() |
18
|
|
|
{ |
19
|
|
|
$this->expectException(\InvalidArgumentException::class); |
20
|
|
|
new Currency('', 'COD', 2, ['RANDOM'], '128'); |
21
|
|
|
} |
22
|
|
|
|
23
|
|
|
public function testExceptionWhenInvalidCode() |
24
|
|
|
{ |
25
|
|
|
$this->expectException(\InvalidArgumentException::class); |
26
|
|
|
new Currency('NAME', 'CODE', 2, ['RANDOM'], '128'); |
27
|
|
|
} |
28
|
|
|
|
29
|
|
|
public function testExceptionWhenEmptyCountryName() |
30
|
|
|
{ |
31
|
|
|
$this->expectException(\InvalidArgumentException::class); |
32
|
|
|
new Currency('NAME', 'COD', 2, [''], '128'); |
33
|
|
|
} |
34
|
|
|
|
35
|
|
|
public function testExceptionWhenInvalidCountryName() |
36
|
|
|
{ |
37
|
|
|
$this->expectException(\InvalidArgumentException::class); |
38
|
|
|
new Currency('NAME', 'COD', 2, [null], '128'); |
39
|
|
|
} |
40
|
|
|
|
41
|
|
|
public function testExceptionWhenNegativeDigits() |
42
|
|
|
{ |
43
|
|
|
$this->expectException(\InvalidArgumentException::class); |
44
|
|
|
new Currency('NAME', 'COD', -1, ['RANDOM'], '128'); |
45
|
|
|
} |
46
|
|
|
|
47
|
|
|
public function testExceptionWhenEmptyNumber() |
48
|
|
|
{ |
49
|
|
|
$this->expectException(\InvalidArgumentException::class); |
50
|
|
|
new Currency('NAME', 'COD', 2, ['RANDOM'], 'A00'); |
51
|
|
|
} |
52
|
|
|
} |
53
|
|
|
|