MDAllowedValueSets/tests/MDNodaRepositoryTest.php

83 lines
5.2 KiB
PHP

<?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 {
self::assertEquals("XX5034943", MDNodaRepository::bne->validateId("http://datos.bne.es/persona/XX5034943"));
self::assertEquals("XX5034943", MDNodaRepository::bne->validateId("https://datos.bne.es/persona/XX5034943"));
self::assertEquals("XX5034943", MDNodaRepository::bne->validateId("XX5034943"));
self::assertEquals(false, MDNodaRepository::bne->validateId("XX503494safdsaf;3"));
// GND (Germany)
self::assertEquals("102423008", MDNodaRepository::gnd->validateId("https://d-nb.info/gnd/102423008"));
self::assertEquals("102423008", MDNodaRepository::gnd->validateId("http://d-nb.info/gnd/102423008"));
self::assertEquals("102423008", MDNodaRepository::gnd->validateId("http://d-nb.info/gnd/ 102423008"));
self::assertEquals("1037602218", MDNodaRepository::gnd->validateId("http://d-nb.info/gnd/1037602218"));
self::assertEquals("1037602218", MDNodaRepository::gnd->validateId("https://explore.gnd.network/gnd/1037602218"));
self::assertEquals("102423008", MDNodaRepository::gnd->validateId("102423008"));
self::assertEquals(false, MDNodaRepository::gnd->validateId("fkld;s102423008"));
// NDL (Japan)
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"));
self::assertEquals("00967046", MDNodaRepository::ndl->validateId("00967046"));
self::assertEquals(false, MDNodaRepository::ndl->validateId("http://id.ndl.go.jp/auth/ndlna/0096704;43s6"));
// NPG: National Portrait Gallery
self::assertEquals('mp01751', MDNodaRepository::npg->validateId("https://www.npg.org.uk/collections/search/person/mp01751"));
self::assertEquals('mp01751', MDNodaRepository::npg->validateId("mp01751"));
self::assertEquals(false, MDNodaRepository::npg->validateId("https://www.npg.org.uk/collections/search/person/mp017;51"));
// Library of Congress
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"));
self::assertEquals(false, MDNodaRepository::loc->validateId("n20220146;04"));
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"));
self::assertEquals("sh85081569", MDNodaRepository::lcsh->validateId("http://id.loc.gov/authorities/subjects/sh85081569.html"));
self::assertEquals("sh2022014604", MDNodaRepository::lcsh->validateId("sh2022014604"));
self::assertEquals(false, MDNodaRepository::lcsh->validateId("sh20220146;;04"));
// PRIM
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"));
self::assertEquals("PIM71684", MDNodaRepository::pim->validateId("PIM71684"));
self::assertEquals(false, MDNodaRepository::pim->validateId("PIM7168;;4"));
self::assertEquals("248941990", MDNodaRepository::viaf->validateId("https://viaf.org/viaf/248941990"));
self::assertEquals("248941990", MDNodaRepository::viaf->validateId("http://viaf.org/viaf/248941990"));
self::assertEquals("42893419", MDNodaRepository::viaf->validateId("https://viaf.org/viaf/42893419/"));
self::assertEquals("86145857811423020454", MDNodaRepository::viaf->validateId("86145857811423020454"));
self::assertEquals("2869150688328112660005", MDNodaRepository::viaf->validateId("2869150688328112660005"));
self::assertEquals(false, MDNodaRepository::viaf->validateId("2869150688328112;;660005"));
# NDP-IKMK (Places)
self::assertEquals("ort/2847", MDNodaRepository::ndp_ikmk->validateId("https://ikmk.smb.museum/ndp/ort/2847"));
self::assertEquals("land/123", MDNodaRepository::ndp_ikmk->validateId("https://ikmk.smb.museum/ndp/land/123"));
self::assertEquals("region/123", MDNodaRepository::ndp_ikmk->validateId("https://ikmk.smb.museum/ndp/region/123"));
self::assertEquals("land/123", MDNodaRepository::ndp_ikmk->validateId("land/123"));
self::assertEquals(false, MDNodaRepository::ndp_ikmk->validateId("123123"));
}
}