2023-11-25 22:42:07 +01:00
< ? PHP
/**
* Tests for setting uniform place names .
*
* @ author Joshua Ramon Enslin < joshua @ museum - digital . de >
*/
declare ( strict_types = 1 );
use PHPUnit\Framework\TestCase ;
/**
* Tests for setting uniform place names .
*
* @ covers \NodaConsolidatedNamesForPlaces
*/
final class NodaConsolidatedNamesForPlacesTest extends TestCase {
/**
* Test that cleanup function returns expected values .
*
* @ small
*
* @ return void
*/
public function testCleaningNamesWithCanonicalForms () : void {
// Hungarian: u. [0-9] > utca.
self :: assertEquals ( " Test u. 12 " , NodaConsolidatedNamesForPlaces :: consolidate_name ( " de " , " Test u. 12 " ));
self :: assertEquals ( " Test utca 12 " , NodaConsolidatedNamesForPlaces :: consolidate_name ( " hu " , " Test u. 12 " ));
self :: assertEquals ( " Test u. Test " , NodaConsolidatedNamesForPlaces :: consolidate_name ( " hu " , " Test u. Test " ));
// German: Ending in standard terms that be in brackets
self :: assertEquals ( " Berlin, Insel Borneo " , NodaConsolidatedNamesForPlaces :: consolidate_name ( " de " , " Berlin, Insel Borneo " ));
self :: assertEquals ( " Berlin (Insel) " , NodaConsolidatedNamesForPlaces :: consolidate_name ( " de " , " Berlin, Insel " ));
self :: assertEquals ( " Berlin, Insel " , NodaConsolidatedNamesForPlaces :: consolidate_name ( " hu " , " Berlin, Insel " ));
// German: Ending in standard terms that be in brackets
self :: assertEquals ( " Adalbrechtstraße 12 " , NodaConsolidatedNamesForPlaces :: consolidate_name ( " de " , " Adalbrechtstr. 12 " ));
self :: assertEquals ( " Adalbrechtstr. 12 " , NodaConsolidatedNamesForPlaces :: consolidate_name ( " hu " , " Adalbrechtstr. 12 " ));
self :: assertEquals ( " Adalbrechtstraße 12 (Berlin) " , NodaConsolidatedNamesForPlaces :: consolidate_name ( " de " , " Berlin, Adalbrechtstr. 12 " ));
self :: assertEquals ( " Adalbrechtstraße 12 (Berlin) " , NodaConsolidatedNamesForPlaces :: consolidate_name ( " de " , " Adalbrechtstr. 12, Berlin " ));
self :: assertEquals ( " Berlin, Adalbrechtstr. 12 " , NodaConsolidatedNamesForPlaces :: consolidate_name ( " hu " , " Berlin, Adalbrechtstr. 12 " ));
2023-11-26 23:55:22 +01:00
self :: assertEquals ( " Ferenc József rakpart 21. Budapest " , NodaConsolidatedNamesForPlaces :: consolidate_name ( " hu " , " Ferenc József rkp. 21. Budapest " ));
self :: assertEquals ( " Ferenc József rkp. 21. Budapest " , NodaConsolidatedNamesForPlaces :: consolidate_name ( " de " , " Ferenc József rkp. 21. Budapest " ));
2023-11-25 22:42:07 +01:00
// Same in Hungarian
self :: assertEquals ( " Adalbrecht utca 12 (Berlin) " , NodaConsolidatedNamesForPlaces :: consolidate_name ( " hu " , " Berlin, Adalbrecht utca 12 " ));
self :: assertEquals ( " Adalbrecht utca 12 (Berlin) " , NodaConsolidatedNamesForPlaces :: consolidate_name ( " hu " , " Adalbrecht utca 12, Berlin " ));
self :: assertEquals ( " Berlin, Adalbrecht utca 12 " , NodaConsolidatedNamesForPlaces :: consolidate_name ( " de " , " Berlin, Adalbrecht utca 12 " ));
// Deák Ferenc utca 16-18. (Budapest, 5. kerület)
self :: assertEquals ( " Deák Ferenc utca 16-18. (Budapest, 5. kerület) " , NodaConsolidatedNamesForPlaces :: consolidate_name ( " hu " , " Deák Ferenc utca 16-18. Budapest, V., " ));
self :: assertEquals ( " Deák Ferenc utca 16-18. (Budapest, 5. kerület) " , NodaConsolidatedNamesForPlaces :: consolidate_name ( " hu " , " Deák Ferenc utca 16-18. Budapest, V. " ));
self :: assertEquals ( " Deák Ferenc utca 16-18. Budapest, V. abc " , NodaConsolidatedNamesForPlaces :: consolidate_name ( " hu " , " Deák Ferenc utca 16-18. Budapest, V. abc " ));
// Rewriting country names in brackets
self :: assertEquals ( " Köln (Deutschland) " , NodaConsolidatedNamesForPlaces :: consolidate_name ( " de " , " Deutschland-Köln " ));
self :: assertEquals ( " Köln (Deutschland) " , NodaConsolidatedNamesForPlaces :: consolidate_name ( " de " , " Deutschland, Köln " ));
self :: assertEquals ( " Köln (Deutschland) " , NodaConsolidatedNamesForPlaces :: consolidate_name ( " de " , " Köln, Deutschland " ));
2023-11-26 23:55:22 +01:00
self :: assertEquals ( " Yue-Öfen " , NodaConsolidatedNamesForPlaces :: consolidate_name ( " de " , " Yue-Öfen " ));
self :: assertEquals ( " Transkei-Distrikt " , NodaConsolidatedNamesForPlaces :: consolidate_name ( " de " , " Transkei-Distrikt " ));
self :: assertEquals ( " Ost-Deutschland " , NodaConsolidatedNamesForPlaces :: consolidate_name ( " de " , " Ost-Deutschland " ));
self :: assertEquals ( " Vaci utca 12 Budapest, Vaci utca " , NodaConsolidatedNamesForPlaces :: consolidate_name ( " hu " , " Vaci utca 12 Budapest, Vaci utca " ));
self :: assertEquals ( " Gambia-Tal " , NodaConsolidatedNamesForPlaces :: consolidate_name ( " hu " , " Gambia-Tal " ));
self :: assertEquals ( " Västerdås, Schweden " , NodaConsolidatedNamesForPlaces :: consolidate_name ( " hu " , " Västerdås, Schweden, Schweden " ));
2023-12-02 15:21:02 +01:00
//
// Ukrainian: Rewrite by hierarchy
//
# self::assertEquals("Приморський (Україна, Запорізька обл., м. Запоріжжя, р -н", NodaConsolidatedNamesForPlaces::consolidate_name("uk", "Україна, Запорізька обл., м. Запоріжжя, Приморський р -н"));
self :: assertEquals ( " Рига (Латвійська Р С Р ) " , NodaConsolidatedNamesForPlaces :: consolidate_name ( " uk " , " Латвійська Р С Р , м.Рига " ));
self :: assertEquals ( " Латвійська Р С Р , м.Рига " , NodaConsolidatedNamesForPlaces :: consolidate_name ( " de " , " Латвійська Р С Р , м.Рига " ));
self :: assertEquals ( " Рига (Латвійська Р С Р , С Р С Р ) " , NodaConsolidatedNamesForPlaces :: consolidate_name ( " uk " , " С Р С Р , Латвійська Р С Р , м.Рига" ));
self :: assertEquals ( " С Р С Р , Латвійська Р С Р , м.Рига" , NodaConsolidatedNamesForPlaces :: consolidate_name ( " de " , " С Р С Р , Латвійська Р С Р , м.Рига" ));
// Steet
self :: assertEquals ( " вул. Шевченка (Рівне) " , NodaConsolidatedNamesForPlaces :: consolidate_name ( " uk " , " м. Рівне, вул. Шевченка " ));
self :: assertEquals ( " м. Рівне, вул. Шевченка " , NodaConsolidatedNamesForPlaces :: consolidate_name ( " de " , " м. Рівне, вул. Шевченка " ));
// Special case: Region can both be rajon or a district within a city
// If both oblast and city are already known, the region will be a
// district within the city.
// Otherwise, it is to be assumed that it is a super-city region.
self :: assertEquals ( " Приморський р -н (Запоріжжя, Запорізька обл., Україна) " , NodaConsolidatedNamesForPlaces :: consolidate_name ( " uk " , " Україна, Запорізька обл., м. Запоріжжя, Приморський р -н " ));
2023-11-25 22:42:07 +01:00
}
}