55 *
66 * PHP version 8
77 *
8- * Copyright (C) The National Library of Finland 2020-2023 .
8+ * Copyright (C) The National Library of Finland 2020-2025 .
99 *
1010 * This program is free software; you can redistribute it and/or modify
1111 * it under the terms of the GNU General Public License version 2,
@@ -98,6 +98,8 @@ public function testMarc1()
9898 'tutkimus ' ,
9999 'Remes, Pirkko ' ,
100100 'Sajavaara, Paula ' ,
101+ 'Example Distributor ' ,
102+ 'distributor ' ,
101103 'urn:doi:doi2 ' ,
102104 'urn:doif:not-doi ' ,
103105 'http://doi.org/doi%3a3 ' ,
@@ -130,8 +132,12 @@ public function testMarc1()
130132 '' ,
131133 '' ,
132134 ],
133- 'author_corporate ' => [],
134- 'author_corporate_role ' => [],
135+ 'author_corporate ' => [
136+ 'Example Distributor ' ,
137+ ],
138+ 'author_corporate_role ' => [
139+ 'distributor ' ,
140+ ],
135141 'author_additional ' => [],
136142 'title ' => 'Tutki ja kirjoita ' ,
137143 'title_sub ' => '' ,
@@ -232,6 +238,10 @@ public function testMarc1()
232238 'type ' => 'author ' ,
233239 'value ' => 'Sajavaara, Paula. ' ,
234240 ],
241+ [
242+ 'type ' => 'author ' ,
243+ 'value ' => 'Example Distributor ' ,
244+ ],
235245 ],
236246 'authorsAltScript ' => [],
237247 'titles ' => [
@@ -803,13 +813,13 @@ public static function getTestMarcLinkingData(): Generator
803813 *
804814 * @param array $firstExpects First expected links
805815 * @param array $secondExpects Second expected links
806- * @param array $conf Main configuration
816+ * @param array $config Main configuration
807817 * @param int $searchCount Record db search expect
808818 *
809819 * @return void
810820 * @dataProvider getTestMarcLinkingData
811821 */
812- public function testMarcLinking (array $ firstExpects , array $ secondExpects , array $ conf , int $ searchCount = 5 )
822+ public function testMarcLinking (array $ firstExpects , array $ secondExpects , array $ config , int $ searchCount = 5 )
813823 {
814824 $ db = $ this ->createMock (Database::class);
815825 $ map = [
@@ -855,7 +865,7 @@ public function testMarcLinking(array $firstExpects, array $secondExpects, array
855865 ->method ('findRecord ' )
856866 ->will ($ this ->returnValueMap ($ map ));
857867
858- $ record = $ this ->createMarcRecord (Marc::class, 'marc_links.xml ' , config: $ conf );
868+ $ record = $ this ->createMarcRecord (Marc::class, 'marc_links.xml ' , config: $ config );
859869 $ record ->toSolrArray ($ db );
860870 $ marc = new \VuFind \Marc \MarcReader ($ record ->serialize ());
861871 $ marc776 = $ marc ->getFields ('776 ' );
@@ -873,7 +883,7 @@ public function testMarcLinking(array $firstExpects, array $secondExpects, array
873883 'driverParams ' => ['003InLinkingID=true ' ],
874884 ],
875885 ],
876- config: $ conf
886+ config: $ config
877887 );
878888 $ record ->toSolrArray ($ db );
879889 $ marc = new \VuFind \Marc \MarcReader ($ record ->serialize ());
@@ -992,4 +1002,216 @@ public function testGetWorkIdentificationData()
9921002 ];
9931003 $ this ->compareArray ($ expected , $ keys , 'getWorkIdentificationData ' );
9941004 }
1005+
1006+ /**
1007+ * Test hidden author relator
1008+ *
1009+ * @return void
1010+ */
1011+ public function testHiddenRelator ()
1012+ {
1013+ $ config = [
1014+ 'MarcRecord ' => [
1015+ 'hidden_author_relators ' => 'distributor ' ,
1016+ ],
1017+ ];
1018+ $ record = $ this ->createMarcRecord (Marc::class, 'marc1.xml ' , config: $ config );
1019+ $ fields = $ record ->toSolrArray ();
1020+ unset($ fields ['fullrecord ' ]);
1021+
1022+ $ expected = [
1023+ 'record_format ' => 'marc ' ,
1024+ 'building ' => [
1025+ '150 ' ,
1026+ '150 ' ,
1027+ ],
1028+ 'lccn ' => '' ,
1029+ 'ctrlnum ' => [
1030+ 'FCC005246184 ' ,
1031+ '378890 ' ,
1032+ '401416 ' ,
1033+ ],
1034+ 'allfields ' => [
1035+ 'Hirsjärvi, Sirkka ' ,
1036+ 'Tutki ja kirjoita ' ,
1037+ 'Sirkka Hirsjärvi, Pirkko Remes, Paula Sajavaara ' ,
1038+ '17. uud. p. ' ,
1039+ 'Helsinki ' ,
1040+ 'Tammi ' ,
1041+ '2345 [2013?] ' ,
1042+ 'teksti ' ,
1043+ 'txt ' ,
1044+ 'rdacontent ' ,
1045+ 'käytettävissä ilman laitetta ' ,
1046+ 'n ' ,
1047+ 'rdamedia ' ,
1048+ 'nide ' ,
1049+ 'nc ' ,
1050+ 'rdacarrier ' ,
1051+ '18. p. 2013 ' ,
1052+ 'Summary field ' ,
1053+ 'oppaat ' ,
1054+ 'ft: kirjoittaminen ' ,
1055+ 'apurahat ' ,
1056+ 'tutkimusrahoitus ' ,
1057+ 'tutkimuspolitiikka ' ,
1058+ 'opinnäytteet ' ,
1059+ 'tiedonhaku ' ,
1060+ 'kielioppaat ' ,
1061+ 'tutkimustyö ' ,
1062+ 'tutkimus ' ,
1063+ 'Remes, Pirkko ' ,
1064+ 'Sajavaara, Paula ' ,
1065+ 'Example Distributor ' ,
1066+ 'distributor ' ,
1067+ 'urn:doi:doi2 ' ,
1068+ 'urn:doif:not-doi ' ,
1069+ 'http://doi.org/doi%3a3 ' ,
1070+ 'https://dx.doi.org/doi4 ' ,
1071+ ],
1072+ 'language ' => [
1073+ 'fin ' ,
1074+ 'fin ' ,
1075+ ],
1076+ 'format ' => ['Book ' ],
1077+ 'author ' => [
1078+ 'Hirsjärvi, Sirkka ' ,
1079+ ],
1080+ 'author_variant ' => [
1081+ 's h sh ' ,
1082+ ],
1083+ 'author_role ' => [
1084+ '' ,
1085+ ],
1086+ 'author_sort ' => 'Hirsjärvi, Sirkka ' ,
1087+ 'author2 ' => [
1088+ 'Remes, Pirkko ' ,
1089+ 'Sajavaara, Paula ' ,
1090+ ],
1091+ 'author2_variant ' => [
1092+ 'p r pr ' ,
1093+ 'p s ps ' ,
1094+ ],
1095+ 'author2_role ' => [
1096+ '' ,
1097+ '' ,
1098+ ],
1099+ 'author_corporate ' => [],
1100+ 'author_corporate_role ' => [],
1101+ 'author_additional ' => [],
1102+ 'title ' => 'Tutki ja kirjoita ' ,
1103+ 'title_sub ' => '' ,
1104+ 'title_short ' => 'Tutki ja kirjoita ' ,
1105+ 'title_full ' => 'Tutki ja kirjoita / Sirkka Hirsjärvi, Pirkko Remes, '
1106+ . ' Paula Sajavaara ' ,
1107+ 'title_alt ' => [],
1108+ 'title_old ' => [],
1109+ 'title_new ' => [],
1110+ 'title_sort ' => 'tutki ja kirjoita sirkka hirsjärvi pirkko remes '
1111+ . ' paula sajavaara ' ,
1112+ 'series ' => [],
1113+ 'publisher ' => [
1114+ 'Tammi ' ,
1115+ ],
1116+ 'publishDateSort ' => '2013 ' ,
1117+ 'publishDate ' => [
1118+ '2013 ' ,
1119+ ],
1120+ 'physical ' => [],
1121+ 'dateSpan ' => [],
1122+ 'edition ' => '17. uud. p. ' ,
1123+ 'contents ' => [],
1124+ 'isbn ' => [
1125+ '9789513148362 ' ,
1126+ ],
1127+ 'issn ' => [],
1128+ 'doi_str_mv ' => [
1129+ 'doi1 ' ,
1130+ 'doi2 ' ,
1131+ 'doi:3 ' ,
1132+ 'doi4 ' ,
1133+ ],
1134+ 'callnumber-first ' => 'QC861.2 ' ,
1135+ 'callnumber-raw ' => [
1136+ '38.04 ' ,
1137+ '38.03 ' ,
1138+ 'QC861.2 .B36 ' ,
1139+ ],
1140+ 'callnumber-subject ' => 'QC ' ,
1141+ 'callnumber-label ' => 'QC861 ' ,
1142+ 'callnumber-sort ' => 'QC 3861.2 B236 ' ,
1143+ 'topic ' => [
1144+ 'oppaat ' ,
1145+ 'ft: kirjoittaminen ' ,
1146+ 'apurahat ' ,
1147+ 'tutkimusrahoitus ' ,
1148+ 'tutkimuspolitiikka ' ,
1149+ 'opinnäytteet ' ,
1150+ 'tiedonhaku ' ,
1151+ 'kielioppaat ' ,
1152+ 'tutkimustyö ' ,
1153+ 'tutkimus ' ,
1154+ ],
1155+ 'genre ' => [],
1156+ 'geographic ' => [],
1157+ 'era ' => [],
1158+ 'topic_facet ' => [
1159+ 'oppaat ' ,
1160+ 'ft: kirjoittaminen ' ,
1161+ 'apurahat ' ,
1162+ 'tutkimusrahoitus ' ,
1163+ 'tutkimuspolitiikka ' ,
1164+ 'opinnäytteet ' ,
1165+ 'tiedonhaku ' ,
1166+ 'kielioppaat ' ,
1167+ 'tutkimustyö ' ,
1168+ 'tutkimus ' ,
1169+ ],
1170+ 'genre_facet ' => [],
1171+ 'geographic_facet ' => [],
1172+ 'era_facet ' => [],
1173+ 'url ' => [
1174+ 'urn:doi:doi2 ' ,
1175+ 'urn:doif:not-doi ' ,
1176+ 'http://doi.org/doi%3a3 ' ,
1177+ 'https://dx.doi.org/doi4 ' ,
1178+ ],
1179+ 'illustrated ' => 'Not Illustrated ' ,
1180+ ];
1181+
1182+ $ this ->compareArray ($ expected , $ fields , 'toSolrArray ' );
1183+
1184+ $ keys = $ record ->getWorkIdentificationData ();
1185+
1186+ $ expected = [
1187+ [
1188+ 'authors ' => [
1189+ [
1190+ 'type ' => 'author ' ,
1191+ 'value ' => 'Hirsjärvi, Sirkka. ' ,
1192+ ],
1193+ [
1194+ 'type ' => 'author ' ,
1195+ 'value ' => 'Remes, Pirkko. ' ,
1196+ ],
1197+ [
1198+ 'type ' => 'author ' ,
1199+ 'value ' => 'Sajavaara, Paula. ' ,
1200+ ],
1201+ ],
1202+ 'authorsAltScript ' => [],
1203+ 'titles ' => [
1204+ [
1205+ 'type ' => 'title ' ,
1206+ 'value ' => 'Tutki ja kirjoita / ' ,
1207+ ],
1208+ ],
1209+ 'titlesAltScript ' => [],
1210+ ],
1211+ ];
1212+
1213+ $ this ->compareArray ($ expected , $ keys , 'getWorkIdentificationData ' );
1214+
1215+ $ this ->assertEquals (['(FOO)2345 ' ], $ record ->getUniqueIDs ());
1216+ }
9951217}
0 commit comments