1 | <?php |
||
16 | class SiteLinkListTest extends \PHPUnit_Framework_TestCase { |
||
17 | |||
18 | /** |
||
19 | * @dataProvider notSiteLinksProvider |
||
20 | */ |
||
21 | public function testGivenNonSiteLinks_constructorThrowsException( array $notSiteLinks ) { |
||
25 | |||
26 | public function notSiteLinksProvider() { |
||
27 | return [ |
||
28 | [ |
||
29 | [ |
||
30 | null |
||
31 | ] |
||
32 | ], |
||
33 | |||
34 | [ |
||
35 | [ |
||
36 | 42 |
||
37 | ] |
||
38 | ], |
||
39 | |||
40 | [ |
||
41 | [ |
||
42 | new SiteLink( 'foo', 'bar' ), |
||
43 | 42, |
||
44 | new SiteLink( 'baz', 'bah' ), |
||
45 | ] |
||
46 | ], |
||
47 | ]; |
||
48 | } |
||
49 | |||
50 | /** |
||
51 | * @dataProvider siteLinkArrayProvider |
||
52 | */ |
||
53 | public function testInputRoundtripsUsingIteratorToArray( array $siteLinkArray ) { |
||
57 | |||
58 | public function siteLinkArrayProvider() { |
||
59 | return [ |
||
60 | [ |
||
61 | [ |
||
62 | ] |
||
63 | ], |
||
64 | |||
65 | [ |
||
66 | [ |
||
67 | new SiteLink( 'foo', 'bar' ) |
||
68 | ] |
||
69 | ], |
||
70 | |||
71 | [ |
||
72 | [ |
||
73 | new SiteLink( 'foo', 'bar' ), |
||
74 | new SiteLink( 'baz', 'bah' ), |
||
75 | new SiteLink( 'hax', 'bar' ), |
||
76 | ] |
||
77 | ], |
||
78 | ]; |
||
79 | } |
||
80 | |||
81 | public function testEmptyCollectionHasZeroSize() { |
||
85 | |||
86 | /** |
||
87 | * @dataProvider siteLinkArrayWithDuplicateSiteIdProvider |
||
88 | */ |
||
89 | public function testGivenSiteIdTwice_constructorThrowsException( array $siteLinkArray ) { |
||
93 | |||
94 | public function siteLinkArrayWithDuplicateSiteIdProvider() { |
||
95 | return [ |
||
96 | [ |
||
97 | [ |
||
98 | new SiteLink( 'foo', 'bar' ), |
||
99 | new SiteLink( 'foo', 'bar' ), |
||
100 | ] |
||
101 | ], |
||
102 | |||
103 | [ |
||
104 | [ |
||
105 | new SiteLink( 'foo', 'one' ), |
||
106 | new SiteLink( 'baz', 'two' ), |
||
107 | new SiteLink( 'foo', 'tree' ), |
||
108 | ] |
||
109 | ], |
||
110 | ]; |
||
111 | } |
||
112 | |||
113 | public function testGetIteratorReturnsTraversableWithSiteIdKeys() { |
||
114 | $list = new SiteLinkList( [ |
||
115 | new SiteLink( 'first', 'one' ), |
||
116 | new SiteLink( 'second', 'two' ), |
||
117 | new SiteLink( 'third', 'tree' ), |
||
118 | ] ); |
||
119 | |||
120 | $this->assertEquals( |
||
121 | [ |
||
122 | 'first' => new SiteLink( 'first', 'one' ), |
||
123 | 'second' => new SiteLink( 'second', 'two' ), |
||
124 | 'third' => new SiteLink( 'third', 'tree' ), |
||
125 | ], |
||
126 | iterator_to_array( $list ) |
||
127 | ); |
||
128 | } |
||
129 | |||
130 | public function testGivenNonString_getBySiteIdThrowsException() { |
||
136 | |||
137 | public function testGivenUnknownSiteId_getBySiteIdThrowsException() { |
||
145 | |||
146 | public function testGivenKnownSiteId_getBySiteIdReturnsSiteLink() { |
||
153 | |||
154 | /** |
||
155 | * @dataProvider siteLinkArrayProvider |
||
156 | */ |
||
157 | public function testGivenTheSameSet_equalsReturnsTrue( array $links ) { |
||
162 | |||
163 | public function testGivenNonSiteLinkList_equalsReturnsFalse() { |
||
168 | |||
169 | public function testGivenDifferentList_equalsReturnsFalse() { |
||
182 | |||
183 | public function testGivenSetWithDifferentOrder_equalsReturnsTrue() { |
||
196 | |||
197 | public function testGivenNonSiteId_removeSiteWithIdThrowsException() { |
||
203 | |||
204 | public function testGivenKnownId_removeSiteWithIdRemovesIt() { |
||
215 | |||
216 | public function testGivenUnknownId_removeSiteWithIdDoesNoOp() { |
||
228 | |||
229 | public function testDifferentInstancesWithSameBadgesAreEqual() { |
||
241 | |||
242 | public function testAddNewSiteLink() { |
||
253 | |||
254 | public function testAddSiteLink() { |
||
265 | |||
266 | public function testToArray() { |
||
278 | |||
279 | public function testGivenNewSiteLink_setSiteLinkAddsIt() { |
||
288 | |||
289 | public function testGivenSiteLinkWithExistingId_setSiteLinkReplacesIt() { |
||
301 | |||
302 | public function testGivenNewSiteLink_setNewSiteLinkAddsIt() { |
||
311 | |||
312 | public function testGivenSiteLinkWithExistingId_setNewSiteLinkReplacesIt() { |
||
324 | |||
325 | public function testEmptyListHasCountZero() { |
||
326 | $this->assertSame( 0, ( new SiteLinkList() )->count() ); |
||
327 | } |
||
328 | |||
329 | public function testListWithElementsHasCorrectCount() { |
||
337 | |||
338 | } |
||
339 |
It seems like the type of the argument is not accepted by the function/method which you are calling.
In some cases, in particular if PHP’s automatic type-juggling kicks in this might be fine. In other cases, however this might be a bug.
We suggest to add an explicit type cast like in the following example: