2021-05-04 23:04:41 +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/NodaNameSplitter.php";
|
|
|
|
require_once __DIR__ . "/../../MD_STD/src/MD_STD.php";
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Tests for home page.
|
|
|
|
*/
|
|
|
|
final class NodaNameSplitterTest extends TestCase {
|
|
|
|
/**
|
|
|
|
* Test to check whether the HTML page is correctly generated.
|
|
|
|
*
|
|
|
|
* @author Joshua Ramon Enslin <joshua@museum-digital.de>
|
|
|
|
* @group ValidOutput
|
|
|
|
*
|
|
|
|
* @return void
|
|
|
|
*/
|
|
|
|
public function testSplitGivenNameFamilyNameFromString():void {
|
|
|
|
|
|
|
|
$splitter = new NodaNameSplitter('de');
|
|
|
|
// This applied to all languages
|
|
|
|
self::assertEquals($splitter->givenNameFamilyNameFromString('Wilhelm'), ['family_name' => '', 'given_name' => 'Wilhelm']);
|
|
|
|
|
|
|
|
self::assertEquals($splitter->givenNameFamilyNameFromString('Friedrich Wilhelm'), ['family_name' => 'Wilhelm', 'given_name' => 'Friedrich']);
|
|
|
|
self::assertEquals($splitter->givenNameFamilyNameFromString('Wilhelm, Friedrich '), ['family_name' => 'Wilhelm', 'given_name' => 'Friedrich']);
|
|
|
|
self::assertEquals($splitter->givenNameFamilyNameFromString('Therese von Bacheracht'), ['family_name' => 'Bacheracht', 'given_name' => 'Therese von']);
|
|
|
|
self::assertEquals($splitter->givenNameFamilyNameFromString('Bacheracht, Therese von'), ['family_name' => 'Bacheracht', 'given_name' => 'Therese von']);
|
|
|
|
self::assertEquals($splitter->givenNameFamilyNameFromString('von Bacheracht, Therese '), ['family_name' => 'Therese', 'given_name' => 'von Bacheracht,']);
|
|
|
|
self::assertEquals($splitter->givenNameFamilyNameFromString('Filomeno V. Aguilar, Jr.'), ['family_name' => 'Jr.', 'given_name' => 'Filomeno V. Aguilar,']);
|
|
|
|
|
|
|
|
$splitter = new NodaNameSplitter('hu');
|
|
|
|
self::assertEquals($splitter->givenNameFamilyNameFromString('Friedrich Wilhelm'), ['family_name' => 'Friedrich', 'given_name' => 'Wilhelm']);
|
|
|
|
self::assertEquals($splitter->givenNameFamilyNameFromString('Wilhelm, Friedrich '), ['family_name' => 'Wilhelm,', 'given_name' => 'Friedrich']);
|
|
|
|
self::assertEquals($splitter->givenNameFamilyNameFromString('Therese von Bacheracht'), ['family_name' => 'Therese', 'given_name' => 'von Bacheracht']);
|
|
|
|
self::assertEquals($splitter->givenNameFamilyNameFromString('Bacheracht, Therese von'), ['family_name' => 'Bacheracht,', 'given_name' => 'Therese von']);
|
|
|
|
self::assertEquals($splitter->givenNameFamilyNameFromString('von Bacheracht, Therese '), ['family_name' => 'von', 'given_name' => 'Bacheracht, Therese']);
|
|
|
|
self::assertEquals($splitter->givenNameFamilyNameFromString('Filomeno V. Aguilar, Jr.'), ['family_name' => 'Filomeno', 'given_name' => 'V. Aguilar, Jr.']);
|
|
|
|
|
|
|
|
}
|
2021-05-04 23:57:30 +02:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Tests the assembly of full names based on given name and family name.
|
|
|
|
*
|
|
|
|
* @author Joshua Ramon Enslin <joshua@museum-digital.de>
|
|
|
|
* @group ValidOutput
|
|
|
|
*
|
|
|
|
* @return void
|
|
|
|
*/
|
|
|
|
public function testAssembleNameParts():void {
|
|
|
|
|
|
|
|
$splitter = new NodaNameSplitter('de');
|
|
|
|
// This applied to all languages
|
|
|
|
self::assertEquals($splitter->assembleNameParts('Friedrich', 'Wilhelm', ' (1910-1920)'), 'Friedrich Wilhelm (1910-1920)');
|
|
|
|
|
|
|
|
$splitter = new NodaNameSplitter('hu');
|
|
|
|
self::assertEquals($splitter->assembleNameParts('Friedrich', 'Wilhelm'), "Wilhelm Friedrich");
|
|
|
|
|
|
|
|
}
|
2021-05-04 23:04:41 +02:00
|
|
|
}
|