MDNodaHelpers/tests/NodaConsolidatedNamesForPlacesTest.php

64 lines
3.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"));
// 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"));
}
}