Complex classes like StatementListTest often do a lot of different things. To break such a class down, we need to identify a cohesive component within that class. A common approach to find such a component is to look for fields/methods that share the same prefixes, or suffixes. You can also have a look at the cohesion graph to spot any un-connected, or weakly-connected components.
Once you have determined the fields that belong together, you can apply the Extract Class refactoring. If the component makes sense as a sub-class, Extract Subclass is also a candidate, and is often faster.
While breaking up the class, it is a good idea to analyze how other classes use StatementListTest, and based on these observations, apply Extract Interface, too.
1 | <?php |
||
25 | class StatementListTest extends \PHPUnit_Framework_TestCase { |
||
26 | |||
27 | /** |
||
28 | * @param int $propertyId |
||
29 | * @param string|null $guid |
||
30 | * @param int $rank |
||
31 | * |
||
32 | * @return Statement |
||
33 | */ |
||
34 | private function getStatement( $propertyId, $guid, $rank = Statement::RANK_NORMAL ) { |
||
35 | $statement = $this->getMockBuilder( 'Wikibase\DataModel\Statement\Statement' ) |
||
36 | ->disableOriginalConstructor() |
||
37 | ->getMock(); |
||
38 | |||
39 | $statement->expects( $this->any() ) |
||
40 | ->method( 'getGuid' ) |
||
41 | ->will( $this->returnValue( $guid ) ); |
||
42 | |||
43 | $statement->expects( $this->any() ) |
||
44 | ->method( 'getPropertyId' ) |
||
45 | ->will( $this->returnValue( PropertyId::newFromNumber( $propertyId ) ) ); |
||
46 | |||
47 | $statement->expects( $this->any() ) |
||
48 | ->method( 'getRank' ) |
||
49 | ->will( $this->returnValue( $rank ) ); |
||
50 | |||
51 | return $statement; |
||
52 | } |
||
53 | |||
54 | private function getStatementWithSnak( $propertyId, $stringValue ) { |
||
55 | $snak = $this->newSnak( $propertyId, $stringValue ); |
||
56 | $statement = new Statement( $snak ); |
||
57 | $statement->setGuid( sha1( $snak->getHash() ) ); |
||
58 | return $statement; |
||
59 | } |
||
60 | |||
61 | private function newSnak( $propertyId, $stringValue ) { |
||
64 | |||
65 | public function testConstructorAcceptsDuplicatesWithNoGuid() { |
||
66 | $list = new StatementList( |
||
67 | $this->getStatement( 1, null ), |
||
68 | $this->getStatement( 1, null ) |
||
69 | ); |
||
70 | |||
71 | $this->assertSame( 2, $list->count() ); |
||
72 | } |
||
73 | |||
74 | public function testConstructorAcceptsDuplicatesWithSameGuid() { |
||
75 | $list = new StatementList( |
||
76 | $this->getStatement( 1, 'duplicate' ), |
||
77 | $this->getStatement( 1, 'duplicate' ) |
||
78 | ); |
||
79 | |||
80 | $this->assertSame( 2, $list->count() ); |
||
81 | } |
||
82 | |||
83 | public function testGivenNoStatements_getPropertyIdsReturnsEmptyArray() { |
||
87 | |||
88 | public function testGivenStatements_getPropertyIdsReturnsArrayWithoutDuplicates() { |
||
89 | $list = new StatementList( |
||
90 | $this->getStatement( 1, 'kittens' ), |
||
91 | $this->getStatement( 3, 'foo' ), |
||
92 | $this->getStatement( 2, 'bar' ), |
||
93 | $this->getStatement( 2, 'baz' ), |
||
94 | $this->getStatement( 1, 'bah' ) |
||
95 | ); |
||
96 | |||
97 | $this->assertEquals( |
||
98 | array( |
||
99 | 'P1' => new PropertyId( 'P1' ), |
||
100 | 'P3' => new PropertyId( 'P3' ), |
||
101 | 'P2' => new PropertyId( 'P2' ), |
||
102 | ), |
||
103 | $list->getPropertyIds() |
||
104 | ); |
||
105 | } |
||
106 | |||
107 | public function testGivenStatementsWithArrayKeys_toArrayReturnsReindexedArray() { |
||
108 | $statement = $this->getStatement( 1, 'guid' ); |
||
109 | $list = new StatementList( array( 'ignore-me' => $statement ) ); |
||
110 | |||
111 | $this->assertSame( array( 0 => $statement ), $list->toArray() ); |
||
112 | } |
||
113 | |||
114 | public function testGivenSparseArray_toArrayReturnsReindexedArray() { |
||
115 | $statement = $this->getStatement( 1, 'guid' ); |
||
116 | $list = new StatementList( array( 1 => $statement ) ); |
||
117 | |||
118 | $this->assertSame( array( 0 => $statement ), $list->toArray() ); |
||
119 | } |
||
120 | |||
121 | public function testCanIterate() { |
||
122 | $statement = $this->getStatement( 1, 'kittens' ); |
||
123 | $list = new StatementList( $statement ); |
||
124 | |||
125 | foreach ( $list as $statementFormList ) { |
||
126 | $this->assertEquals( $statement, $statementFormList ); |
||
127 | } |
||
128 | } |
||
129 | |||
130 | public function testGetUniqueMainSnaksReturnsListWithoutDuplicates() { |
||
131 | $list = new StatementList( |
||
132 | $this->getStatementWithSnak( 1, 'foo' ), |
||
133 | $this->getStatementWithSnak( 2, 'foo' ), |
||
134 | $this->getStatementWithSnak( 1, 'foo' ), |
||
135 | $this->getStatementWithSnak( 2, 'bar' ), |
||
136 | $this->getStatementWithSnak( 1, 'bar' ) |
||
137 | ); |
||
138 | |||
139 | $this->assertEquals( |
||
140 | array( |
||
141 | $this->getStatementWithSnak( 1, 'foo' ), |
||
142 | $this->getStatementWithSnak( 2, 'foo' ), |
||
143 | $this->getStatementWithSnak( 2, 'bar' ), |
||
144 | $this->getStatementWithSnak( 1, 'bar' ), |
||
145 | ), |
||
146 | array_values( $list->getWithUniqueMainSnaks()->toArray() ) |
||
147 | ); |
||
148 | } |
||
149 | |||
150 | public function testGetAllSnaksReturnsAllSnaks() { |
||
151 | $list = new StatementList( |
||
152 | $this->getStatementWithSnak( 1, 'foo' ), |
||
153 | $this->getStatementWithSnak( 2, 'foo' ), |
||
154 | $this->getStatementWithSnak( 1, 'foo' ), |
||
155 | $this->getStatementWithSnak( 2, 'bar' ), |
||
156 | $this->getStatementWithSnak( 1, 'bar' ) |
||
157 | ); |
||
158 | |||
159 | $this->assertEquals( |
||
160 | array( |
||
161 | $this->newSnak( 1, 'foo' ), |
||
162 | $this->newSnak( 2, 'foo' ), |
||
163 | $this->newSnak( 1, 'foo' ), |
||
164 | $this->newSnak( 2, 'bar' ), |
||
165 | $this->newSnak( 1, 'bar' ), |
||
166 | ), |
||
167 | $list->getAllSnaks() |
||
168 | ); |
||
169 | } |
||
170 | |||
171 | public function testAddStatementWithOnlyMainSnak() { |
||
172 | $list = new StatementList(); |
||
173 | |||
174 | $list->addNewStatement( $this->newSnak( 42, 'foo' ) ); |
||
175 | |||
176 | $this->assertEquals( |
||
177 | new StatementList( new Statement( $this->newSnak( 42, 'foo' ) ) ), |
||
178 | $list |
||
179 | ); |
||
180 | } |
||
181 | |||
182 | public function testAddStatementWithQualifiersAsSnakArray() { |
||
204 | |||
205 | public function testAddStatementWithQualifiersAsSnakList() { |
||
206 | $list = new StatementList(); |
||
207 | $snakList = new SnakList( array( |
||
208 | $this->newSnak( 1, 'bar' ) |
||
209 | ) ); |
||
210 | |||
211 | $list->addNewStatement( |
||
212 | $this->newSnak( 42, 'foo' ), |
||
213 | $snakList |
||
214 | ); |
||
215 | |||
216 | $this->assertEquals( |
||
217 | new StatementList( new Statement( $this->newSnak( 42, 'foo' ), $snakList ) ), |
||
218 | $list |
||
219 | ); |
||
220 | } |
||
221 | |||
222 | public function testAddStatementWithGuid() { |
||
223 | $list = new StatementList(); |
||
224 | |||
225 | $list->addNewStatement( |
||
226 | $this->newSnak( 42, 'foo' ), |
||
227 | null, |
||
228 | null, |
||
229 | 'kittens' |
||
230 | ); |
||
231 | |||
232 | $statement = new Statement( $this->newSnak( 42, 'foo' ) ); |
||
233 | |||
234 | $statement->setGuid( 'kittens' ); |
||
235 | |||
236 | $this->assertEquals( new StatementList( $statement ), $list ); |
||
237 | } |
||
238 | |||
239 | public function testGivenGuidOfPresentStatement_statementIsRemoved() { |
||
240 | $statement1 = new Statement( $this->newSnak( 24, 'foo' ), null, null, 'foo' ); |
||
241 | $statement2 = new Statement( $this->newSnak( 32, 'bar' ), null, null, 'bar' ); |
||
242 | $statement3 = new Statement( $this->newSnak( 32, 'bar' ), null, null, 'bar' ); |
||
243 | |||
244 | $list = new StatementList( array( $statement1, $statement2, $statement3 ) ); |
||
245 | $list->removeStatementsWithGuid( 'foo' ); |
||
246 | |||
247 | $this->assertEquals( new StatementList( $statement2, $statement3 ), $list ); |
||
248 | } |
||
249 | |||
250 | public function testGivenGuidOfMultipleStatements_multipleStatementsAreRemoved() { |
||
251 | $statement1 = new Statement( $this->newSnak( 24, 'foo' ), null, null, 'foo' ); |
||
252 | $statement2 = new Statement( $this->newSnak( 32, 'bar' ), null, null, 'bar' ); |
||
253 | $statement3 = new Statement( $this->newSnak( 32, 'bar' ), null, null, 'bar' ); |
||
254 | |||
255 | $list = new StatementList( array( $statement1, $statement2, $statement3 ) ); |
||
256 | $list->removeStatementsWithGuid( 'bar' ); |
||
257 | |||
258 | $this->assertEquals( new StatementList( $statement1 ), $list ); |
||
259 | } |
||
260 | |||
261 | public function testGivenNotPresentGuid_listIsNotModified() { |
||
262 | $statement1 = new Statement( $this->newSnak( 24, 'foo' ), null, null, 'foo' ); |
||
263 | $statement2 = new Statement( $this->newSnak( 32, 'bar' ), null, null, 'bar' ); |
||
264 | $statement3 = new Statement( $this->newSnak( 32, 'bar' ), null, null, 'bar' ); |
||
265 | |||
266 | $list = new StatementList( array( $statement1, $statement2, $statement3 ) ); |
||
267 | $list->removeStatementsWithGuid( 'baz' ); |
||
268 | |||
269 | $this->assertEquals( new StatementList( $statement1, $statement2, $statement3 ), $list ); |
||
270 | } |
||
271 | |||
272 | public function testGivenNullGuid_allStatementsWithNoGuidAreRemoved() { |
||
273 | $statement1 = new Statement( $this->newSnak( 24, 'foo' ), null, null, 'foo' ); |
||
274 | $statement2 = new Statement( $this->newSnak( 32, 'bar' ) ); |
||
275 | $statement3 = new Statement( $this->newSnak( 32, 'bar' ) ); |
||
276 | |||
277 | $list = new StatementList( array( $statement1, $statement2, $statement3 ) ); |
||
278 | $list->removeStatementsWithGuid( null ); |
||
279 | |||
280 | $this->assertEquals( new StatementList( $statement1 ), $list ); |
||
281 | } |
||
282 | |||
283 | public function testCanConstructWithTraversableContainingOnlyStatements() { |
||
284 | $statementArray = array( |
||
285 | $this->getStatementWithSnak( 1, 'foo' ), |
||
286 | $this->getStatementWithSnak( 2, 'bar' ), |
||
287 | ); |
||
288 | |||
289 | $object = new ArrayObject( $statementArray ); |
||
290 | $list = new StatementList( $object ); |
||
291 | |||
292 | $this->assertEquals( |
||
293 | $statementArray, |
||
294 | array_values( $list->toArray() ) |
||
295 | ); |
||
296 | } |
||
297 | |||
298 | public function testGivenTraversableWithNonStatements_constructorThrowsException() { |
||
299 | $traversable = new ArrayObject( array( |
||
300 | $this->getStatementWithSnak( 1, 'foo' ), |
||
301 | new \stdClass(), |
||
302 | $this->getStatementWithSnak( 2, 'bar' ), |
||
303 | ) ); |
||
304 | |||
305 | $this->setExpectedException( 'InvalidArgumentException' ); |
||
|
|||
306 | new StatementList( $traversable ); |
||
307 | } |
||
308 | |||
309 | public function testGivenNonTraversableOrArgList_constructorThrowsException() { |
||
313 | |||
314 | public function testCanConstructWithStatement() { |
||
315 | $statement = new Statement( $this->newSnak( 42, 'foo' ) ); |
||
316 | |||
317 | $this->assertEquals( |
||
318 | new StatementList( array( $statement ) ), |
||
319 | new StatementList( $statement ) |
||
320 | ); |
||
321 | } |
||
322 | |||
323 | public function testCanConstructWithStatementArgumentList() { |
||
324 | $statement0 = new Statement( $this->newSnak( 42, 'foo' ) ); |
||
325 | $statement1 = new Statement( $this->newSnak( 42, 'bar' ) ); |
||
326 | $statement2 = new Statement( $this->newSnak( 42, 'baz' ) ); |
||
327 | |||
328 | $this->assertEquals( |
||
329 | new StatementList( array( $statement0, $statement1, $statement2 ) ), |
||
330 | new StatementList( $statement0, $statement1, $statement2 ) |
||
331 | ); |
||
332 | } |
||
333 | |||
334 | public function testGivenArgumentListWithNonStatement_constructorThrowsException() { |
||
335 | $statement0 = new Statement( $this->newSnak( 42, 'foo' ) ); |
||
336 | $statement1 = new Statement( $this->newSnak( 42, 'bar' ) ); |
||
337 | $statement2 = new Statement( $this->newSnak( 42, 'baz' ) ); |
||
338 | |||
339 | $this->setExpectedException( 'InvalidArgumentException' ); |
||
340 | new StatementList( $statement0, $statement1, array(), $statement2 ); |
||
341 | } |
||
342 | |||
343 | public function testCountForEmptyList() { |
||
344 | $list = new StatementList(); |
||
345 | $this->assertSame( 0, count( $list ) ); |
||
346 | $this->assertSame( 0, $list->count() ); |
||
347 | } |
||
348 | |||
349 | public function testCountForNonEmptyList() { |
||
350 | $list = new StatementList( |
||
351 | $this->getStatementWithSnak( 1, 'foo' ), |
||
352 | $this->getStatementWithSnak( 2, 'bar' ) |
||
353 | ); |
||
354 | |||
355 | $this->assertSame( 2, $list->count() ); |
||
356 | } |
||
357 | |||
358 | /** |
||
359 | * @dataProvider statementArrayProvider |
||
360 | */ |
||
361 | public function testGivenIdenticalLists_equalsReturnsTrue( array $statements ) { |
||
362 | $firstStatements = new StatementList( $statements ); |
||
363 | $secondStatements = new StatementList( $statements ); |
||
364 | |||
365 | $this->assertTrue( $firstStatements->equals( $secondStatements ) ); |
||
366 | } |
||
367 | |||
368 | public function statementArrayProvider() { |
||
369 | return array( |
||
370 | array( array( |
||
371 | $this->getStatementWithSnak( 1, 'foo' ), |
||
372 | $this->getStatementWithSnak( 2, 'bar' ), |
||
373 | ) ), |
||
374 | array( array( |
||
375 | $this->getStatementWithSnak( 1, 'foo' ), |
||
376 | ) ), |
||
377 | array( array( |
||
378 | ) ), |
||
379 | ); |
||
380 | } |
||
381 | |||
382 | public function testGivenDifferentLists_equalsReturnsFalse() { |
||
383 | $firstStatements = new StatementList( |
||
384 | $this->getStatementWithSnak( 1, 'foo' ), |
||
385 | $this->getStatementWithSnak( 2, 'bar' ) |
||
386 | ); |
||
387 | |||
388 | $secondStatements = new StatementList( |
||
389 | $this->getStatementWithSnak( 1, 'foo' ), |
||
390 | $this->getStatementWithSnak( 2, 'SPAM' ) |
||
391 | ); |
||
392 | |||
393 | $this->assertFalse( $firstStatements->equals( $secondStatements ) ); |
||
394 | } |
||
395 | |||
396 | public function testGivenListsWithDifferentDuplicates_equalsReturnsFalse() { |
||
397 | $firstStatements = new StatementList( |
||
398 | $this->getStatementWithSnak( 1, 'foo' ), |
||
399 | $this->getStatementWithSnak( 1, 'foo' ), |
||
400 | $this->getStatementWithSnak( 2, 'bar' ) |
||
401 | ); |
||
402 | |||
403 | $secondStatements = new StatementList( |
||
404 | $this->getStatementWithSnak( 1, 'foo' ), |
||
405 | $this->getStatementWithSnak( 2, 'bar' ), |
||
406 | $this->getStatementWithSnak( 2, 'bar' ) |
||
407 | ); |
||
408 | |||
409 | $this->assertFalse( $firstStatements->equals( $secondStatements ) ); |
||
410 | } |
||
411 | |||
412 | public function testGivenListsWithDifferentOrder_equalsReturnsFalse() { |
||
413 | $firstStatements = new StatementList( |
||
414 | $this->getStatementWithSnak( 1, 'foo' ), |
||
415 | $this->getStatementWithSnak( 2, 'bar' ), |
||
416 | $this->getStatementWithSnak( 3, 'baz' ) |
||
417 | ); |
||
418 | |||
419 | $secondStatements = new StatementList( |
||
420 | $this->getStatementWithSnak( 1, 'foo' ), |
||
421 | $this->getStatementWithSnak( 3, 'baz' ), |
||
422 | $this->getStatementWithSnak( 2, 'bar' ) |
||
423 | ); |
||
424 | |||
425 | $this->assertFalse( $firstStatements->equals( $secondStatements ) ); |
||
426 | } |
||
427 | |||
428 | public function testEmptyListDoesNotEqualNonEmptyList() { |
||
429 | $firstStatements = new StatementList(); |
||
430 | |||
431 | $secondStatements = new StatementList( |
||
432 | $this->getStatementWithSnak( 1, 'foo' ), |
||
433 | $this->getStatementWithSnak( 3, 'baz' ), |
||
434 | $this->getStatementWithSnak( 2, 'bar' ) |
||
435 | ); |
||
436 | |||
437 | $this->assertFalse( $firstStatements->equals( $secondStatements ) ); |
||
438 | } |
||
439 | |||
440 | public function testNonEmptyListDoesNotEqualEmptyList() { |
||
441 | $firstStatements = new StatementList( |
||
442 | $this->getStatementWithSnak( 1, 'foo' ), |
||
443 | $this->getStatementWithSnak( 3, 'baz' ), |
||
444 | $this->getStatementWithSnak( 2, 'bar' ) |
||
445 | ); |
||
446 | |||
447 | $secondStatements = new StatementList(); |
||
448 | |||
449 | $this->assertFalse( $firstStatements->equals( $secondStatements ) ); |
||
450 | } |
||
451 | |||
452 | public function testEmptyListIsEmpty() { |
||
453 | $list = new StatementList(); |
||
454 | |||
455 | $this->assertTrue( $list->isEmpty() ); |
||
456 | } |
||
457 | |||
458 | public function testNonEmptyListIsNotEmpty() { |
||
459 | $list = new StatementList( $this->getStatementWithSnak( 1, 'foo' ) ); |
||
460 | |||
461 | $this->assertFalse( $list->isEmpty() ); |
||
462 | } |
||
463 | |||
464 | public function testGetMainSnaks() { |
||
465 | $list = new StatementList(); |
||
466 | |||
467 | $list->addNewStatement( new PropertyNoValueSnak( 42 ) ); |
||
468 | $list->addNewStatement( new PropertyNoValueSnak( 1337 ), array( new PropertyNoValueSnak( 32202 ) ) ); |
||
469 | $list->addNewStatement( new PropertyNoValueSnak( 9001 ) ); |
||
470 | |||
471 | $this->assertEquals( |
||
472 | array( |
||
473 | new PropertyNoValueSnak( 42 ), |
||
474 | new PropertyNoValueSnak( 1337 ), |
||
475 | new PropertyNoValueSnak( 9001 ), |
||
476 | ), |
||
477 | $list->getMainSnaks() |
||
478 | ); |
||
479 | } |
||
480 | |||
481 | public function testGivenNotKnownPropertyId_getByPropertyIdReturnsEmptyList() { |
||
482 | $list = new StatementList(); |
||
483 | $list->addNewStatement( new PropertyNoValueSnak( 42 ) ); |
||
484 | |||
485 | $this->assertEquals( |
||
486 | new StatementList(), |
||
487 | $list->getByPropertyId( new PropertyId( 'P2' ) ) |
||
488 | ); |
||
489 | } |
||
490 | |||
491 | public function testGivenKnownPropertyId_getByPropertyIdReturnsListWithOnlyMatchingStatements() { |
||
492 | $list = new StatementList(); |
||
493 | $list->addNewStatement( new PropertyNoValueSnak( 42 ) ); |
||
494 | $list->addNewStatement( new PropertyNoValueSnak( 9001 ) ); |
||
495 | $list->addNewStatement( new PropertySomeValueSnak( 42 ) ); |
||
496 | $list->addNewStatement( new PropertySomeValueSnak( 9001 ) ); |
||
497 | |||
498 | $expected = new StatementList(); |
||
499 | $expected->addNewStatement( new PropertyNoValueSnak( 42 ) ); |
||
500 | $expected->addNewStatement( new PropertySomeValueSnak( 42 ) ); |
||
501 | |||
502 | $this->assertEquals( |
||
503 | $expected, |
||
504 | $list->getByPropertyId( new PropertyId( 'P42' ) ) |
||
505 | ); |
||
506 | } |
||
507 | |||
508 | public function testGivenInvalidRank_getByRankReturnsEmptyList() { |
||
509 | $list = new StatementList(); |
||
510 | $this->assertEquals( new StatementList(), $list->getByRank( 42 ) ); |
||
511 | } |
||
512 | |||
513 | public function testGivenValidRank_getByRankReturnsOnlyMatchingStatements() { |
||
514 | $statement = new Statement( new PropertyNoValueSnak( 42 ) ); |
||
515 | $statement->setRank( Statement::RANK_PREFERRED ); |
||
516 | |||
517 | $secondStatement = new Statement( new PropertyNoValueSnak( 1337 ) ); |
||
518 | $secondStatement->setRank( Statement::RANK_NORMAL ); |
||
519 | |||
520 | $thirdStatement = new Statement( new PropertyNoValueSnak( 9001 ) ); |
||
521 | $thirdStatement->setRank( Statement::RANK_DEPRECATED ); |
||
522 | |||
523 | $list = new StatementList( $statement, $secondStatement, $thirdStatement ); |
||
524 | |||
525 | $this->assertEquals( |
||
526 | new StatementList( $statement ), |
||
527 | $list->getByRank( Statement::RANK_PREFERRED ) |
||
528 | ); |
||
529 | |||
530 | $this->assertEquals( |
||
531 | new StatementList( $secondStatement, $thirdStatement ), |
||
532 | $list->getByRank( array( Statement::RANK_NORMAL, Statement::RANK_DEPRECATED ) ) |
||
533 | ); |
||
534 | } |
||
535 | |||
536 | public function testWhenListIsEmpty_getBestStatementsReturnsEmptyList() { |
||
540 | |||
541 | public function testWhenOnlyDeprecatedStatements_getBestStatementsReturnsEmptyList() { |
||
542 | $statement = new Statement( new PropertyNoValueSnak( 42 ) ); |
||
543 | $statement->setRank( Statement::RANK_DEPRECATED ); |
||
544 | |||
545 | $secondStatement = new Statement( new PropertyNoValueSnak( 9001 ) ); |
||
546 | $secondStatement->setRank( Statement::RANK_DEPRECATED ); |
||
547 | |||
548 | $list = new StatementList( $statement, $secondStatement ); |
||
549 | $this->assertEquals( new StatementList(), $list->getBestStatements() ); |
||
550 | } |
||
551 | |||
552 | public function testWhenPreferredStatements_getBestStatementsReturnsOnlyThose() { |
||
553 | $statement = new Statement( new PropertyNoValueSnak( 42 ) ); |
||
554 | $statement->setRank( Statement::RANK_PREFERRED ); |
||
555 | |||
556 | $secondStatement = new Statement( new PropertyNoValueSnak( 1337 ) ); |
||
557 | $secondStatement->setRank( Statement::RANK_NORMAL ); |
||
558 | |||
559 | $thirdStatement = new Statement( new PropertyNoValueSnak( 9001 ) ); |
||
560 | $thirdStatement->setRank( Statement::RANK_DEPRECATED ); |
||
561 | |||
562 | $fourthStatement = new Statement( new PropertyNoValueSnak( 23 ) ); |
||
563 | $fourthStatement->setRank( Statement::RANK_PREFERRED ); |
||
564 | |||
565 | $list = new StatementList( $statement, $secondStatement, $thirdStatement, $fourthStatement ); |
||
566 | $this->assertEquals( |
||
567 | new StatementList( $statement, $fourthStatement ), |
||
568 | $list->getBestStatements() |
||
569 | ); |
||
570 | } |
||
571 | |||
572 | public function testWhenNoPreferredStatements_getBestStatementsReturnsOnlyNormalOnes() { |
||
573 | $statement = new Statement( new PropertyNoValueSnak( 42 ) ); |
||
574 | $statement->setRank( Statement::RANK_NORMAL ); |
||
588 | |||
589 | public function testGivenNotPresentStatement_getFirstStatementWithGuidReturnsNull() { |
||
594 | |||
595 | public function testGivenPresentStatement_getFirstStatementWithGuidReturnsStatement() { |
||
604 | |||
605 | public function testGivenDoublyPresentStatement_getFirstStatementWithGuidReturnsFirstMatch() { |
||
615 | |||
616 | public function testGivenStatementsWithNoGuid_getFirstStatementWithGuidReturnsFirstMatch() { |
||
624 | |||
625 | public function testGivenInvalidGuid_getFirstStatementWithGuidReturnsNull() { |
||
630 | |||
631 | public function testFilter() { |
||
632 | $statement1 = new Statement( new PropertyNoValueSnak( 1 ) ); |
||
633 | $statement2 = new Statement( new PropertyNoValueSnak( 2 ) ); |
||
634 | $statement3 = new Statement( new PropertyNoValueSnak( 3 ) ); |
||
635 | $statement4 = new Statement( new PropertyNoValueSnak( 4 ) ); |
||
636 | |||
652 | |||
653 | public function testClear() { |
||
662 | |||
663 | } |
||
664 |
This method has been deprecated. The supplier of the class has supplied an explanatory message.
The explanatory message should give you some clue as to whether and when the method will be removed from the class and what other method or class to use instead.