@@ -908,4 +908,98 @@ public function testGetLandingPageUrlOfDocForId()
908908 $ manager ->getLandingPageUrlOfDoc ($ docId )
909909 );
910910 }
911+
912+ public function testGetAllDoiValues ()
913+ {
914+ $ doiValues = [
915+ '10.0000/1111 ' ,
916+ '10.0000/2222 ' ,
917+ '10.0000/3333 ' ,
918+ ];
919+
920+ foreach ($ doiValues as $ doi ) {
921+ $ doc = Document::new ();
922+ $ identifier = $ doc ->addIdentifier ();
923+ $ identifier ->setType ('doi ' );
924+ $ identifier ->setValue ($ doi );
925+ $ doc ->store ();
926+ }
927+
928+ // other identifier type than DOI
929+ $ identifier = $ doc ->addIdentifier ();
930+ $ identifier ->setType ('isbn ' );
931+ $ identifier ->setValue ('isbn-value ' );
932+
933+ // duplicate DOI identifier
934+ $ identifier = $ doc ->addIdentifier ();
935+ $ identifier ->setType ('doi ' );
936+ $ identifier ->setValue ('10.0000/3333 ' );
937+
938+ $ doc ->store ();
939+
940+ $ manager = new DoiManager ();
941+
942+ $ values = $ manager ->getAllDoiValues ();
943+
944+ $ this ->assertCount (3 , $ values );
945+ $ this ->assertEquals ($ doiValues , $ values );
946+ }
947+
948+ public function testGetAllDoiValuesNonFound ()
949+ {
950+ $ manager = new DoiManager ();
951+
952+ $ values = $ manager ->getAllDoiValues ();
953+
954+ $ this ->assertIsArray ($ values );
955+ $ this ->assertEmpty ($ values );
956+ }
957+
958+ public function testGetDuplicateDoiValues ()
959+ {
960+ $ doi1 = '10.1000/1111 ' ;
961+ $ doi2 = '10.1000/2222 ' ;
962+
963+ $ doc = Document::new ();
964+ $ doi = $ doc ->addIdentifier ();
965+ $ doi ->setType ('doi ' );
966+ $ doi ->setValue ($ doi1 );
967+ $ doc ->store ();
968+
969+ $ doc = Document::new ();
970+ $ doi = $ doc ->addIdentifier ();
971+ $ doi ->setType ('doi ' );
972+ $ doi ->setValue ($ doi1 );
973+ $ doc ->store ();
974+
975+ $ doc = Document::new ();
976+ $ doi = $ doc ->addIdentifier ();
977+ $ doi ->setType ('doi ' );
978+ $ doi ->setValue ($ doi2 );
979+ $ doc ->store ();
980+
981+ // other identifier type than DOI
982+ $ doc = Document::new ();
983+ $ identifier = $ doc ->addIdentifier ();
984+ $ identifier ->setType ('isbn ' );
985+ $ identifier ->setValue ('isbn-value ' );
986+ $ doc ->store ();
987+
988+ $ manager = new DoiManager ();
989+
990+ $ values = $ manager ->getDuplicateDoiValues ();
991+
992+ $ this ->assertCount (1 , $ values );
993+ $ this ->assertEquals ($ doi1 , $ values [0 ]);
994+ }
995+
996+ public function testGetDuplicateDoiValuesNonFound ()
997+ {
998+ $ manager = new DoiManager ();
999+
1000+ $ values = $ manager ->getDuplicateDoiValues ();
1001+
1002+ $ this ->assertIsArray ($ values );
1003+ $ this ->assertEmpty ($ values );
1004+ }
9111005}
0 commit comments