@@ -503,120 +503,6 @@ public function testDuplicateClaims() {
503503 $ this ->assertNull ( $ list ->getClaimWithGuid ( $ secondClaim ->getGuid () ) );
504504 }
505505
506- public function getDiffProvider () {
507- $ argLists = array ();
508-
509- $ claim0 = $ this ->makeClaim ( new PropertyNoValueSnak ( 42 ) );
510- $ claim1 = $ this ->makeClaim ( new PropertySomeValueSnak ( 42 ) );
511- $ claim2 = $ this ->makeClaim ( new PropertyValueSnak ( 42 , new StringValue ( 'ohi ' ) ) );
512- $ claim3 = $ this ->makeClaim ( new PropertyNoValueSnak ( 1 ) );
513- $ claim4 = $ this ->makeClaim ( new PropertyNoValueSnak ( 2 ) );
514-
515- $ statement0 = $ this ->makeStatement ( new PropertyNoValueSnak ( 5 ) );
516- $ statement0 ->setRank ( Statement::RANK_PREFERRED );
517-
518- $ statement1 = $ this ->makeStatement ( new PropertyNoValueSnak ( 5 ) );
519- $ statement1 ->setReferences ( new ReferenceList ( array ( new Reference (
520- new SnakList ( array ( new PropertyValueSnak ( 10 , new StringValue ( 'spam ' ) ) ) )
521- ) ) ) );
522-
523- // same GUID, changed main snak
524- $ claim2v2 = unserialize ( serialize ( $ claim2 ) );
525- $ claim2v2 ->setMainSnak ( new PropertyValueSnak ( 42 , new StringValue ( 'omnomnom ' ) ) );
526-
527- // different GUID, same contents, same hash
528- $ claim0a = unserialize ( serialize ( $ claim0 ) );
529- $ claim0a ->setGuid ( 'TEST$claim0x ' );
530- $ claim0a ->setMainSnak ( new PropertyValueSnak ( 99 , new StringValue ( 'frob ' ) ) );
531-
532- // same GUID as $claim0a, same content/hash as $claim0
533- $ claim0b = unserialize ( serialize ( $ claim0 ) );
534- $ claim0b ->setGuid ( 'TEST$claim0x ' );
535-
536- $ source = new Claims ();
537- $ target = new Claims ();
538- $ expected = new Diff ( array (), true );
539- $ argLists [] = array ( $ source , $ target , $ expected , 'Two empty lists should result in an empty diff ' );
540-
541-
542- $ source = new Claims ();
543- $ target = new Claims ( array ( $ claim0 ) );
544- $ expected = new Diff ( array ( $ claim0 ->getGuid () => new DiffOpAdd ( $ claim0 ) ), true );
545- $ argLists [] = array ( $ source , $ target , $ expected , 'List with no entries to list with one should result in one add op ' );
546-
547-
548- $ source = new Claims ( array ( $ claim0 ) );
549- $ target = new Claims ();
550- $ expected = new Diff ( array ( $ claim0 ->getGuid () => new DiffOpRemove ( $ claim0 ) ), true );
551- $ argLists [] = array ( $ source , $ target , $ expected , 'List with one entry to an empty list should result in one remove op ' );
552-
553-
554- $ source = new Claims ( array ( $ claim0 , $ claim3 , $ claim2 ) );
555- $ target = new Claims ( array ( $ claim0 , $ claim2 , $ claim3 ) );
556- $ expected = new Diff ( array (), true );
557- $ argLists [] = array ( $ source , $ target , $ expected , 'Two identical lists should result in an empty diff ' );
558-
559-
560- $ source = new Claims ( array ( $ claim0 ) );
561- $ target = new Claims ( array ( $ claim1 ) );
562- $ expected = new Diff ( array (
563- $ claim1 ->getGuid () => new DiffOpAdd ( $ claim1 ),
564- $ claim0 ->getGuid () => new DiffOpRemove ( $ claim0 )
565- ), true );
566- $ argLists [] = array ( $ source , $ target , $ expected , 'Two lists with each a single different entry should result into one add and one remove op ' );
567-
568-
569- $ source = new Claims ( array ( $ claim2 , $ claim3 , $ claim0 , $ claim4 ) );
570- $ target = new Claims ( array ( $ claim2 , $ claim1 , $ claim3 , $ claim4 ) );
571- $ expected = new Diff ( array (
572- $ claim1 ->getGuid () => new DiffOpAdd ( $ claim1 ),
573- $ claim0 ->getGuid () => new DiffOpRemove ( $ claim0 )
574- ), true );
575- $ argLists [] = array ( $ source , $ target , $ expected , 'Two lists with identical items except for one change should result in one add and one remove op ' );
576-
577-
578- $ source = new Claims ( array ( $ claim0 , $ claim0 , $ claim3 , $ claim2 , $ claim2 , $ claim2 , $ statement0 ) );
579- $ target = new Claims ( array ( $ claim0 , $ claim0 , $ claim2 , $ claim3 , $ claim2 , $ claim2 , $ statement0 ) );
580- $ expected = new Diff ( array (), true );
581- $ argLists [] = array ( $ source , $ target , $ expected , 'Two identical lists with duplicate items should result in an empty diff ' );
582-
583-
584- $ source = new Claims ( array ( $ statement0 , $ statement1 , $ claim0 ) );
585- $ target = new Claims ( array ( $ claim1 , $ claim1 , $ claim0 , $ statement1 ) );
586- $ expected = new Diff ( array (
587- $ claim1 ->getGuid () => new DiffOpAdd ( $ claim1 ),
588- $ statement0 ->getGuid () => new DiffOpRemove ( $ statement0 ),
589- ), true );
590- $ argLists [] = array ( $ source , $ target , $ expected , 'Two lists with duplicate items and a different entry should result into one add and one remove op ' );
591-
592- $ source = new Claims ( array ( $ claim0 , $ claim3 , $ claim2 ) );
593- $ target = new Claims ( array ( $ claim0 , $ claim2v2 , $ claim3 ) );
594- $ expected = new Diff ( array ( $ claim2 ->getGuid () => new DiffOpChange ( $ claim2 , $ claim2v2 ) ), true );
595- $ argLists [] = array ( $ source , $ target , $ expected , 'Changing the value of a claim should result in a change op ' );
596-
597- $ source = new Claims ( array ( $ claim0 , $ claim0a ) );
598- $ target = new Claims ( array ( $ claim0 , $ claim0b ) );
599- $ expected = new Diff ( array ( $ claim0a ->getGuid () => new DiffOpChange ( $ claim0a , $ claim0b ) ), true );
600- $ argLists [] = array ( $ source , $ target , $ expected , 'It should be possible for a claim to become the same as another claim ' );
601-
602- return $ argLists ;
603- }
604-
605- /**
606- * @dataProvider getDiffProvider
607- *
608- * @param Claims $source
609- * @param Claims $target
610- * @param Diff $expected
611- * @param string $message
612- */
613- public function testGetDiff ( Claims $ source , Claims $ target , Diff $ expected , $ message ) {
614- $ actual = $ source ->getDiff ( $ target );
615-
616- // Note: this makes order of inner arrays relevant, and this order is not guaranteed by the interface
617- $ this ->assertEquals ( $ expected ->getOperations (), $ actual ->getOperations (), $ message );
618- }
619-
620506 public function testGetHash () {
621507 $ claimsA = new Claims ();
622508 $ claimsB = new Claims ();
0 commit comments