2023-07-25 22:33:57 +02:00
|
|
|
<?PHP
|
|
|
|
/**
|
|
|
|
* This script contains tests for the home page.
|
|
|
|
*
|
|
|
|
* @author Joshua Ramon Enslin <joshua@museum-digital.de>
|
|
|
|
*/
|
|
|
|
declare(strict_types = 1);
|
|
|
|
use PHPUnit\Framework\TestCase;
|
|
|
|
|
|
|
|
require_once __DIR__ . '/../src/enums/MDValueEnumInterface.php';
|
|
|
|
require_once __DIR__ . '/../src/enums/MDNodaRepository.php';
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Tests for home page.
|
|
|
|
*/
|
|
|
|
final class MDNodaRepositoryTest extends TestCase {
|
|
|
|
/**
|
|
|
|
* Tests that valid IDs actually validate as valid.
|
|
|
|
*
|
|
|
|
* @return void
|
|
|
|
*/
|
|
|
|
public function testValidIdsValidate():void {
|
|
|
|
|
2023-09-01 12:30:47 +02:00
|
|
|
self::assertEquals("XX5034943", MDNodaRepository::bne->validateId("http://datos.bne.es/persona/XX5034943"));
|
2023-10-18 22:42:49 +02:00
|
|
|
self::assertEquals("XX5034943", MDNodaRepository::bne->validateId("https://datos.bne.es/persona/XX5034943"));
|
2023-09-01 12:30:47 +02:00
|
|
|
self::assertEquals("XX5034943", MDNodaRepository::bne->validateId("XX5034943"));
|
2023-10-18 22:42:49 +02:00
|
|
|
self::assertEquals(false, MDNodaRepository::bne->validateId("XX503494safdsaf;3"));
|
2023-09-01 12:30:47 +02:00
|
|
|
|
2023-07-25 22:33:57 +02:00
|
|
|
// GND (Germany)
|
2023-08-03 17:20:03 +02:00
|
|
|
self::assertEquals("102423008", MDNodaRepository::gnd->validateId("https://d-nb.info/gnd/102423008"));
|
|
|
|
self::assertEquals("102423008", MDNodaRepository::gnd->validateId("http://d-nb.info/gnd/102423008"));
|
2023-10-16 16:44:33 +02:00
|
|
|
self::assertEquals("102423008", MDNodaRepository::gnd->validateId("http://d-nb.info/gnd/ 102423008"));
|
2023-10-18 22:35:31 +02:00
|
|
|
self::assertEquals("1037602218", MDNodaRepository::gnd->validateId("http://d-nb.info/gnd/1037602218"));
|
2023-08-03 17:20:03 +02:00
|
|
|
self::assertEquals("102423008", MDNodaRepository::gnd->validateId("102423008"));
|
2023-10-18 22:42:49 +02:00
|
|
|
self::assertEquals(false, MDNodaRepository::gnd->validateId("fkld;s102423008"));
|
2023-07-25 22:33:57 +02:00
|
|
|
|
|
|
|
// NDL (Japan)
|
2023-08-03 17:20:03 +02:00
|
|
|
self::assertEquals("00967046", MDNodaRepository::ndl->validateId("https://id.ndl.go.jp/auth/ndlna/00967046"));
|
|
|
|
self::assertEquals("00967046", MDNodaRepository::ndl->validateId("http://id.ndl.go.jp/auth/ndlna/00967046"));
|
2023-10-18 22:42:49 +02:00
|
|
|
self::assertEquals("00967046", MDNodaRepository::ndl->validateId("00967046"));
|
|
|
|
self::assertEquals(false, MDNodaRepository::ndl->validateId("http://id.ndl.go.jp/auth/ndlna/0096704;43s6"));
|
2023-07-25 22:33:57 +02:00
|
|
|
|
|
|
|
// NPG: National Portrait Gallery
|
2023-10-15 18:30:18 +02:00
|
|
|
self::assertEquals('mp01751', MDNodaRepository::npg->validateId("https://www.npg.org.uk/collections/search/person/mp01751"));
|
2023-10-18 22:42:49 +02:00
|
|
|
self::assertEquals('mp01751', MDNodaRepository::npg->validateId("mp01751"));
|
|
|
|
self::assertEquals(false, MDNodaRepository::npg->validateId("https://www.npg.org.uk/collections/search/person/mp017;51"));
|
2023-07-25 22:33:57 +02:00
|
|
|
|
|
|
|
// Library of Congress
|
2023-08-03 17:20:03 +02:00
|
|
|
self::assertEquals("n2022014604", MDNodaRepository::loc->validateId("https://id.loc.gov/authorities/names/n2022014604"));
|
|
|
|
self::assertEquals("n2022014604", MDNodaRepository::loc->validateId("http://id.loc.gov/authorities/names/n2022014604"));
|
|
|
|
self::assertEquals("n2022014604", MDNodaRepository::loc->validateId("n2022014604"));
|
2023-10-18 22:42:49 +02:00
|
|
|
self::assertEquals(false, MDNodaRepository::loc->validateId("n20220146;04"));
|
2023-07-25 22:33:57 +02:00
|
|
|
|
2023-08-03 17:20:03 +02:00
|
|
|
self::assertEquals("sh2022014604", MDNodaRepository::lcsh->validateId("https://id.loc.gov/authorities/names/sh2022014604"));
|
|
|
|
self::assertEquals("sh2022014604", MDNodaRepository::lcsh->validateId("http://id.loc.gov/authorities/names/sh2022014604"));
|
2023-10-15 18:30:18 +02:00
|
|
|
self::assertEquals("sh85081569", MDNodaRepository::lcsh->validateId("http://id.loc.gov/authorities/subjects/sh85081569.html"));
|
2023-10-18 22:42:49 +02:00
|
|
|
self::assertEquals("sh2022014604", MDNodaRepository::lcsh->validateId("sh2022014604"));
|
|
|
|
self::assertEquals(false, MDNodaRepository::lcsh->validateId("sh20220146;;04"));
|
2023-07-25 22:33:57 +02:00
|
|
|
|
2023-10-18 22:42:49 +02:00
|
|
|
// PRIM
|
2023-09-01 12:30:47 +02:00
|
|
|
self::assertEquals("PIM71684", MDNodaRepository::pim->validateId("https://opac-nevter.pim.hu/en/record/-/record/PIM71684"));
|
|
|
|
self::assertEquals("PIM71684", MDNodaRepository::pim->validateId("https://resolver.pim.hu/auth/PIM71684"));
|
2023-10-18 22:42:49 +02:00
|
|
|
self::assertEquals("PIM71684", MDNodaRepository::pim->validateId("PIM71684"));
|
|
|
|
self::assertEquals(false, MDNodaRepository::pim->validateId("PIM7168;;4"));
|
2023-08-03 17:20:03 +02:00
|
|
|
|
|
|
|
self::assertEquals("248941990", MDNodaRepository::viaf->validateId("https://viaf.org/viaf/248941990"));
|
|
|
|
self::assertEquals("248941990", MDNodaRepository::viaf->validateId("http://viaf.org/viaf/248941990"));
|
2023-10-18 22:42:49 +02:00
|
|
|
self::assertEquals("86145857811423020454", MDNodaRepository::viaf->validateId("86145857811423020454"));
|
|
|
|
self::assertEquals("2869150688328112660005", MDNodaRepository::viaf->validateId("2869150688328112660005"));
|
|
|
|
self::assertEquals(false, MDNodaRepository::viaf->validateId("2869150688328112;;660005"));
|
2023-07-27 19:24:16 +02:00
|
|
|
|
2023-07-25 22:33:57 +02:00
|
|
|
}
|
|
|
|
}
|