forked from z38/swiss-payment
-
Notifications
You must be signed in to change notification settings - Fork 6
/
Copy pathIIDTest.php
112 lines (99 loc) · 2.19 KB
/
IIDTest.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
<?php
namespace Z38\SwissPayment\Tests;
use DOMDocument;
use DOMXPath;
use InvalidArgumentException;
use Z38\SwissPayment\IBAN;
use Z38\SwissPayment\IID;
/**
* @coversDefaultClass \Z38\SwissPayment\IID
*/
class IIDTest extends TestCase
{
/**
* @dataProvider validSamples
* @covers ::__construct
*/
public function testValid($iid)
{
$this->assertInstanceOf('Z38\SwissPayment\IID', new IID($iid));
}
/**
* @return string[][]
*/
public function validSamples()
{
return [
['9222'],
['00432'],
];
}
/**
* @dataProvider invalidSamples
* @covers ::__construct
*/
public function testInvalidLength($iid)
{
$this->expectException(InvalidArgumentException::class);
new IID($iid);
}
/**
* @return string[][]
*/
public function invalidSamples()
{
return [
['00000000'],
['10000000'],
['11'],
['FFF'],
['0 11'],
];
}
/**
* @covers ::format
*/
public function testFormat()
{
$instance = new IID('350');
$this->assertSame('00350', $instance->format());
}
/**
* @dataProvider fromIBANSamples
* @covers ::fromIBAN
*/
public function testFromIBAN($iban, $iid)
{
$instance = IID::fromIBAN(new IBAN($iban));
$this->assertSame($iid, $instance->format());
}
/**
* @return string[][]
*/
public function fromIBANSamples()
{
return [
['CH31 8123 9000 0012 4568 9', '81239'],
['LI21 0881 0000 2324 013A A', '08810'],
];
}
/**
* @cover ::fromIban
*/
public function testFromIBANForeign()
{
$this->expectException(InvalidArgumentException::class);
IID::fromIBAN(new IBAN('GB29 NWBK 6016 1331 9268 19'));
}
/**
* @cover ::asDom
*/
public function testAsDom()
{
$doc = new DOMDocument();
$iid = new IID('09000');
$xml = $iid->asDom($doc);
$xpath = new DOMXPath($doc);
$this->assertSame('9000', $xpath->evaluate('string(.//MmbId)', $xml));
}
}