1
|
|
|
<?php |
2
|
|
|
/** |
3
|
|
|
* Copyright (c) 2014-2016 Ryan Parman. |
4
|
|
|
* |
5
|
|
|
* Permission is hereby granted, free of charge, to any person obtaining a copy |
6
|
|
|
* of this software and associated documentation files (the "Software"), to deal |
7
|
|
|
* in the Software without restriction, including without limitation the rights |
8
|
|
|
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell |
9
|
|
|
* copies of the Software, and to permit persons to whom the Software is |
10
|
|
|
* furnished to do so, subject to the following conditions: |
11
|
|
|
* |
12
|
|
|
* The above copyright notice and this permission notice shall be included in |
13
|
|
|
* all copies or substantial portions of the Software. |
14
|
|
|
* |
15
|
|
|
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR |
16
|
|
|
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, |
17
|
|
|
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE |
18
|
|
|
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER |
19
|
|
|
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, |
20
|
|
|
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN |
21
|
|
|
* THE SOFTWARE. |
22
|
|
|
* |
23
|
|
|
* http://opensource.org/licenses/MIT |
24
|
|
|
*/ |
25
|
|
|
|
26
|
|
|
namespace Skyzyx\Tests\StrongTypes; |
27
|
|
|
|
28
|
|
|
use Skyzyx\StrongTypes\OneOfCollection; |
29
|
|
|
|
30
|
|
|
class OneOfCollectionTest extends \PHPUnit_Framework_TestCase |
31
|
|
|
{ |
32
|
|
|
public function testOneOfCollectionValid1() |
33
|
|
|
{ |
34
|
|
|
$this->assertEquals('', ''); // Shut-up, test runner |
35
|
|
|
|
36
|
|
|
new TestOneOfCollection([ |
37
|
|
|
'key1' => true, |
38
|
|
|
]); |
39
|
|
|
new TestOneOfCollection([ |
40
|
|
|
'key2' => true, |
41
|
|
|
]); |
42
|
|
|
new TestOneOfCollection([ |
43
|
|
|
'key3' => true, |
44
|
|
|
]); |
45
|
|
|
new TestOneOfCollection([ |
46
|
|
|
'key1' => true, |
47
|
|
|
'key2' => true, |
48
|
|
|
]); |
49
|
|
|
new TestOneOfCollection([ |
50
|
|
|
'key2' => true, |
51
|
|
|
'key3' => true, |
52
|
|
|
]); |
53
|
|
|
new TestOneOfCollection([ |
54
|
|
|
'key1' => true, |
55
|
|
|
'key3' => true, |
56
|
|
|
]); |
57
|
|
|
new TestOneOfCollection([ |
58
|
|
|
'key1' => true, |
59
|
|
|
'key2' => true, |
60
|
|
|
'key3' => true, |
61
|
|
|
]); |
62
|
|
|
new TestOneOfCollection([ |
63
|
|
|
'key3' => true, |
64
|
|
|
'key4' => true, |
65
|
|
|
]); |
66
|
|
|
new TestOneOfCollection([ |
67
|
|
|
'key2' => true, |
68
|
|
|
'key3' => true, |
69
|
|
|
'key4' => true, |
70
|
|
|
]); |
71
|
|
|
new TestOneOfCollection([ |
72
|
|
|
'key1' => true, |
73
|
|
|
'key2' => true, |
74
|
|
|
'key3' => true, |
75
|
|
|
'key4' => true, |
76
|
|
|
]); |
77
|
|
|
} |
78
|
|
|
|
79
|
|
|
public function testOneOfCollectionValid2() |
80
|
|
|
{ |
81
|
|
|
$this->assertEquals('', ''); // Shut-up, test runner |
82
|
|
|
|
83
|
|
|
new OneOfCollection([ |
84
|
|
|
'key1' => true, |
85
|
|
|
]); |
86
|
|
|
} |
87
|
|
|
|
88
|
|
|
/** |
89
|
|
|
* @expectedException UnexpectedValueException |
90
|
|
|
* @expectedExceptionMessage The collection did not contain any of the required fields: key1, key2, key3 |
91
|
|
|
*/ |
92
|
|
|
public function testOneOfCollectionFail() |
93
|
|
|
{ |
94
|
|
|
$this->assertEquals('', ''); // Shut-up, test runner |
95
|
|
|
|
96
|
|
|
new TestOneOfCollection([ |
97
|
|
|
'key4' => true, |
98
|
|
|
]); |
99
|
|
|
} |
100
|
|
|
|
101
|
|
|
/** |
102
|
|
|
* @expectedException UnexpectedValueException |
103
|
|
|
* @expectedExceptionMessage The `requireOneKey()` method must return an indexed array. |
104
|
|
|
*/ |
105
|
|
|
public function testOneOfCollectionFail2() |
106
|
|
|
{ |
107
|
|
|
$this->assertEquals('', ''); // Shut-up, test runner |
108
|
|
|
|
109
|
|
|
new TestOneOfCollection2([ |
110
|
|
|
'key1' => true, |
111
|
|
|
]); |
112
|
|
|
} |
113
|
|
|
} |
114
|
|
|
|