Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add unit tests to verify parsing and normalisation of vietnamese names #20

Merged
merged 1 commit into from
Jun 3, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion src/Name.php
Original file line number Diff line number Diff line change
Expand Up @@ -173,7 +173,7 @@ public function getMiddlename(): string
* helper method used by getters to extract and format relevant name parts
*
* @param string $type
* @param bool $pure
* @param bool $strict
* @return string
*/
protected function export(string $type, bool $strict = false): string
Expand Down
2 changes: 1 addition & 1 deletion src/Part/AbstractPart.php
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,7 @@ protected function camelcase($word): string
protected function camelcaseReplace($matches): string
{
if (function_exists('mb_convert_case')) {
return mb_convert_case($matches[0], MB_CASE_TITLE, "UTF-8");
return mb_convert_case($matches[0], MB_CASE_TITLE, 'UTF-8');
}

return ucfirst(strtolower($matches[0]));
Expand Down
8 changes: 8 additions & 0 deletions tests/ParserTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -487,6 +487,14 @@ public function provider()
'initials' => 'M.',
'suffix' => 'Jr',
]
],
[
'Thái Quốc Nguyễn',
[
'lastname' => 'Nguyễn',
'middlename' => 'Quốc',
'firstname' => 'Thái',
]
]
];
}
Expand Down
6 changes: 6 additions & 0 deletions tests/Part/NormalisationTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,12 @@ public function testCamelcasingWorksWithMbString()

$part = new Firstname('etna');
$this->assertEquals('Etna', $part->normalize());

$part = new Firstname('thái');
$this->assertEquals('Thái', $part->normalize());

$part = new Lastname('nguyễn');
$this->assertEquals('Nguyễn', $part->normalize());
}

/**
Expand Down