@@ -449,38 +449,11 @@ public function testSetLabel( $languageCode, $labelText, $moarText = 'ohi there'
449449
450450 $ entity ->setLabel ( $ languageCode , $ labelText );
451451
452- $ this ->assertEquals ( $ labelText , $ entity ->getLabel ( $ languageCode ) );
452+ $ this ->assertEquals ( $ labelText , $ entity ->getFingerprint ()-> getLabel ( $ languageCode )-> getText ( ) );
453453
454454 $ entity ->setLabel ( $ languageCode , $ moarText );
455455
456- $ this ->assertEquals ( $ moarText , $ entity ->getLabel ( $ languageCode ) );
457- }
458-
459- /**
460- * @dataProvider labelProvider
461- * @param string $languageCode
462- * @param string $labelText
463- */
464- public function testGetLabel ( $ languageCode , $ labelText ) {
465- $ entity = $ this ->getNewEmpty ();
466-
467- $ this ->assertFalse ( $ entity ->getLabel ( $ languageCode ) );
468-
469- $ entity ->setLabel ( $ languageCode , $ labelText );
470-
471- $ this ->assertEquals ( $ labelText , $ entity ->getLabel ( $ languageCode ) );
472- }
473-
474- /**
475- * @dataProvider labelProvider
476- * @param string $languageCode
477- * @param string $labelText
478- */
479- public function testRemoveLabel ( $ languageCode , $ labelText ) {
480- $ entity = $ this ->getNewEmpty ();
481- $ entity ->setLabel ( $ languageCode , $ labelText );
482- $ entity ->removeLabel ( $ languageCode );
483- $ this ->assertFalse ( $ entity ->getLabel ( $ languageCode ) );
456+ $ this ->assertEquals ( $ moarText , $ entity ->getFingerprint ()->getLabel ( $ languageCode )->getText () );
484457 }
485458
486459 public function descriptionProvider () {
@@ -502,38 +475,11 @@ public function testSetDescription( $languageCode, $description, $moarText = 'oh
502475
503476 $ entity ->setDescription ( $ languageCode , $ description );
504477
505- $ this ->assertEquals ( $ description , $ entity ->getDescription ( $ languageCode ) );
478+ $ this ->assertEquals ( $ description , $ entity ->getFingerprint ()-> getDescription ( $ languageCode )-> getText ( ) );
506479
507480 $ entity ->setDescription ( $ languageCode , $ moarText );
508481
509- $ this ->assertEquals ( $ moarText , $ entity ->getDescription ( $ languageCode ) );
510- }
511-
512- /**
513- * @dataProvider descriptionProvider
514- * @param string $languageCode
515- * @param string $description
516- */
517- public function testGetDescription ( $ languageCode , $ description ) {
518- $ entity = $ this ->getNewEmpty ();
519-
520- $ this ->assertFalse ( $ entity ->getDescription ( $ languageCode ) );
521-
522- $ entity ->setDescription ( $ languageCode , $ description );
523-
524- $ this ->assertEquals ( $ description , $ entity ->getDescription ( $ languageCode ) );
525- }
526-
527- /**
528- * @dataProvider descriptionProvider
529- * @param string $languageCode
530- * @param string $description
531- */
532- public function testRemoveDescription ( $ languageCode , $ description ) {
533- $ entity = $ this ->getNewEmpty ();
534- $ entity ->setDescription ( $ languageCode , $ description );
535- $ entity ->removeDescription ( $ languageCode );
536- $ this ->assertFalse ( $ entity ->getDescription ( $ languageCode ) );
482+ $ this ->assertEquals ( $ moarText , $ entity ->getFingerprint ()->getDescription ( $ languageCode )->getText () );
537483 }
538484
539485 public function aliasesProvider () {
@@ -561,29 +507,6 @@ public function aliasesProvider() {
561507 );
562508 }
563509
564- /**
565- * @dataProvider aliasesProvider
566- */
567- public function testAddAliases ( array $ aliasesLists ) {
568- $ entity = $ this ->getNewEmpty ();
569-
570- foreach ( $ aliasesLists as $ langCode => $ aliasesList ) {
571- foreach ( $ aliasesList as $ aliases ) {
572- $ entity ->addAliases ( $ langCode , $ aliases );
573- }
574- }
575-
576- foreach ( $ aliasesLists as $ langCode => $ aliasesList ) {
577- $ expected = array_values ( array_unique ( call_user_func_array ( 'array_merge ' , $ aliasesList ) ) );
578- asort ( $ expected );
579-
580- $ actual = $ entity ->getAliases ( $ langCode );
581- asort ( $ actual );
582-
583- $ this ->assertEquals ( $ expected , $ actual );
584- }
585- }
586-
587510 /**
588511 * @dataProvider aliasesProvider
589512 */
@@ -600,7 +523,7 @@ public function testSetAliases( array $aliasesLists ) {
600523 $ expected = array_values ( array_unique ( array_pop ( $ aliasesList ) ) );
601524 asort ( $ aliasesList );
602525
603- $ actual = $ entity ->getAliases ( $ langCode );
526+ $ actual = $ entity ->getFingerprint ()-> getAliasGroup ( $ langCode )-> getAliases ( );
604527 asort ( $ actual );
605528
606529 $ this ->assertEquals ( $ expected , $ actual );
@@ -625,96 +548,7 @@ public function testSetEmptyAlias( array $aliasesLists ) {
625548 $ expected = array_values ( array_unique ( array_pop ( $ aliasesList ) ) );
626549 asort ( $ aliasesList );
627550
628- $ actual = $ entity ->getAliases ( $ langCode );
629- asort ( $ actual );
630-
631- $ this ->assertEquals ( $ expected , $ actual );
632- }
633- }
634-
635- /**
636- * @dataProvider aliasesProvider
637- */
638- public function testSetAllAliases ( array $ aliasGroups ) {
639- $ entity = $ this ->getNewEmpty ();
640- $ entity ->addAliases ( 'zh ' , array ( 'qwertyuiop123 ' , '321poiuytrewq ' ) );
641-
642- $ aliasesToSet = array ();
643- foreach ( $ aliasGroups as $ langCode => $ aliasGroup ) {
644- foreach ( $ aliasGroup as $ aliases ) {
645- $ aliasesToSet [$ langCode ] = $ aliases ;
646- }
647- }
648-
649- $ entity ->setAllAliases ( $ aliasesToSet );
650-
651- foreach ( $ aliasGroups as $ langCode => $ aliasGroup ) {
652- $ expected = array_values ( array_unique ( array_pop ( $ aliasGroup ) ) );
653- asort ( $ aliasGroup );
654-
655- $ actual = $ entity ->getFingerprint ()->getAliasGroups ()->getByLanguage ( $ langCode )->getAliases ();
656- asort ( $ actual );
657-
658- $ this ->assertEquals ( $ expected , $ actual );
659- }
660-
661- /** @var AliasGroup $aliasGroup */
662- foreach ( $ entity ->getFingerprint ()->getAliasGroups () as $ langCode => $ aliasGroup ) {
663- $ this ->assertEquals ( $ aliasGroup ->getAliases (), array_unique ( $ aliasesToSet [$ langCode ] ) );
664- }
665- }
666-
667- public function testGetAliases () {
668- $ entity = $ this ->getNewEmpty ();
669- $ aliases = array ( 'a ' , 'b ' );
670-
671- $ entity ->getFingerprint ()->setAliasGroup ( 'en ' , $ aliases );
672-
673- $ this ->assertEquals (
674- $ aliases ,
675- $ entity ->getAliases ( 'en ' )
676- );
677- }
678-
679- public function duplicateAliasesProvider () {
680- return array (
681- array ( array (
682- 'en ' => array ( array ( 'foo ' , 'bar ' , 'baz ' ), array ( 'foo ' , 'bar ' , 'baz ' ) )
683- ) ),
684- array ( array (
685- 'en ' => array ( array ( 'foo ' , 'bar ' , 'baz ' ), array ( 'foo ' , 'bar ' ) )
686- ) ),
687- array ( array (
688- 'en ' => array ( array ( 'foo ' , 'bar ' ), array ( 'foo ' , 'bar ' , 'baz ' ) )
689- ) ),
690- array ( array (
691- 'en ' => array ( array ( 'foo ' , 'bar ' ), array ( 'bar ' , 'baz ' ) ),
692- 'de ' => array ( array (), array ( 'foo ' ) ),
693- 'nl ' => array ( array ( 'foo ' ), array () ),
694- ) ),
695- array ( array (
696- 'en ' => array ( array ( 'foo ' , 'bar ' , 'baz ' ), array ( 'foo ' , 'bar ' , 'baz ' , 'foo ' , 'bar ' ) )
697- ) ),
698- );
699- }
700-
701- /**
702- * @dataProvider duplicateAliasesProvider
703- */
704- public function testRemoveAliases ( array $ aliasesLists ) {
705- $ entity = $ this ->getNewEmpty ();
706-
707- foreach ( $ aliasesLists as $ langCode => $ aliasesList ) {
708- $ aliases = array_shift ( $ aliasesList );
709- $ removedAliases = array_shift ( $ aliasesList );
710-
711- $ entity ->setAliases ( $ langCode , $ aliases );
712- $ entity ->removeAliases ( $ langCode , $ removedAliases );
713-
714- $ expected = array_values ( array_diff ( $ aliases , $ removedAliases ) );
715- $ actual = $ entity ->getAliases ( $ langCode );
716-
717- asort ( $ expected );
551+ $ actual = $ entity ->getFingerprint ()->getAliasGroup ( $ langCode )->getAliases ();
718552 asort ( $ actual );
719553
720554 $ this ->assertEquals ( $ expected , $ actual );
@@ -851,13 +685,7 @@ public function testGivenEmptyFingerprint_noTermsAreSet() {
851685 $ entity = $ this ->getNewEmpty ();
852686 $ entity ->setFingerprint ( new Fingerprint () );
853687
854- $ this ->assertHasNoTerms ( $ entity );
855- }
856-
857- private function assertHasNoTerms ( Item $ entity ) {
858- $ this ->assertEquals ( array (), $ entity ->getLabels () );
859- $ this ->assertEquals ( array (), $ entity ->getDescriptions () );
860- $ this ->assertEquals ( array (), $ entity ->getAllAliases () );
688+ $ this ->assertTrue ( $ entity ->getFingerprint ()->isEmpty () );
861689 }
862690
863691 public function testGivenEmptyFingerprint_existingTermsAreRemoved () {
@@ -869,7 +697,7 @@ public function testGivenEmptyFingerprint_existingTermsAreRemoved() {
869697
870698 $ entity ->setFingerprint ( new Fingerprint () );
871699
872- $ this ->assertHasNoTerms ( $ entity );
700+ $ this ->assertTrue ( $ entity-> getFingerprint ()-> isEmpty () );
873701 }
874702
875703 public function testWhenSettingFingerprint_getFingerprintReturnsIt () {
@@ -889,7 +717,7 @@ public function testWhenSettingFingerprint_getFingerprintReturnsIt() {
889717 $ entity ->setFingerprint ( $ fingerprint );
890718 $ newFingerprint = $ entity ->getFingerprint ();
891719
892- $ this ->assertEquals ( $ fingerprint , $ newFingerprint );
720+ $ this ->assertSame ( $ fingerprint , $ newFingerprint );
893721 }
894722
895723}
0 commit comments