95 lines
6.5 KiB
PHP
95 lines
6.5 KiB
PHP
<?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"));
|
||
|
||
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"));
|
||
|
||
// 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"));
|
||
|
||
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"));
|
||
|
||
//
|
||
// 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", "Україна, Запорізька обл., м. Запоріжжя, Приморський р-н"));
|
||
|
||
}
|
||
}
|