-
Notifications
You must be signed in to change notification settings - Fork 29
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add unit test to cover normalisation with and without mbstring extension
- Loading branch information
Showing
3 changed files
with
66 additions
and
6 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,57 @@ | ||
<?php | ||
|
||
namespace TheIconic\NameParser\Part; | ||
|
||
use phpmock\phpunit\PHPMock; | ||
use PHPUnit\Framework\TestCase; | ||
|
||
class NormalisationTest extends TestCase | ||
{ | ||
use PHPMock; | ||
|
||
/** | ||
* make sure we test both with and without mb_string support | ||
*/ | ||
public function testCamelcasingWorksWithMbString() | ||
{ | ||
$functionExistsMock = $this->getFunctionMock(__NAMESPACE__, 'function_exists'); | ||
$functionExistsMock->expects($this->any()) | ||
->with('mb_convert_case') | ||
->willReturn(true); | ||
|
||
$part = new Lastname('McDonald'); | ||
$this->assertEquals('McDonald', $part->normalize()); | ||
|
||
$part = new Lastname('übel'); | ||
$this->assertEquals('Übel', $part->normalize()); | ||
|
||
$part = new Firstname('Anne-Marie'); | ||
$this->assertEquals('Anne-Marie', $part->normalize()); | ||
|
||
$part = new Firstname('etna'); | ||
$this->assertEquals('Etna', $part->normalize()); | ||
} | ||
|
||
/** | ||
* make sure we test both with and without mb_string support | ||
*/ | ||
public function testCamelcasingWorksWithoutMbString() | ||
{ | ||
$functionExistsMock = $this->getFunctionMock(__NAMESPACE__, 'function_exists'); | ||
$functionExistsMock->expects($this->any()) | ||
->with('mb_convert_case') | ||
->willReturn(false); | ||
|
||
$part = new Lastname('McDonald'); | ||
$this->assertEquals('McDonald', $part->normalize()); | ||
|
||
$part = new Lastname('ubel'); | ||
$this->assertEquals('Ubel', $part->normalize()); | ||
|
||
$part = new Firstname('Anne-Marie'); | ||
$this->assertEquals('Anne-Marie', $part->normalize()); | ||
|
||
$part = new Firstname('etna'); | ||
$this->assertEquals('Etna', $part->normalize()); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
<?php | ||
|
||
use phpmock\phpunit\PHPMock; | ||
|
||
PHPMock::defineFunctionMock('TheIconic\NameParser\Part', 'function_exists'); | ||
|
||
require dirname(__DIR__) . '/vendor/autoload.php'; |