Skip to content

Commit

Permalink
Merge pull request #20 from theiconic/feature/add-tests-for-vietnames…
Browse files Browse the repository at this point in the history
…e-names

Add unit tests to verify parsing and normalisation of vietnamese names
  • Loading branch information
wyrfel authored Jun 3, 2019
2 parents dbffe73 + 1e791cc commit c6721fc
Show file tree
Hide file tree
Showing 4 changed files with 16 additions and 2 deletions.
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

0 comments on commit c6721fc

Please sign in to comment.