diff options
author | Ivan Enderlin <ivan.enderlin@hoa-project.net> | 2015-01-06 10:58:07 +0100 |
---|---|---|
committer | Ivan Enderlin <ivan.enderlin@hoa-project.net> | 2015-01-06 10:58:07 +0100 |
commit | 5f1e431439306effea7ff8b2dda89c1fd8c543fb (patch) | |
tree | f1d8e00a4e75adfdd1aba0678ad4336e4f6923b9 /Test/Unit | |
parent | ad9ce83656bcbf396274473b98fa4c4e4272d00f (diff) | |
download | Ustring-5f1e431439306effea7ff8b2dda89c1fd8c543fb.zip Ustring-5f1e431439306effea7ff8b2dda89c1fd8c543fb.tar.gz Ustring-5f1e431439306effea7ff8b2dda89c1fd8c543fb.tar.bz2 |
Update toAscii to use a transliterator.
Diffstat (limited to 'Test/Unit')
-rw-r--r-- | Test/Unit/String.php | 68 |
1 files changed, 62 insertions, 6 deletions
diff --git a/Test/Unit/String.php b/Test/Unit/String.php index ccf7e0e..82710ef 100644 --- a/Test/Unit/String.php +++ b/Test/Unit/String.php @@ -848,13 +848,13 @@ class String extends Test\Unit\Suite { ->isTrue(); } - public function case_to_ascii_no_normalizer ( ) { + public function case_to_ascii_no_transliterator_no_normalizer ( ) { $this ->given( $this->function->class_exists = function ( $name ) { - return 'Normalizer' !== $name; + return false === in_array($name, ['Transliterator', 'Normalizer']); }, $string = new LUT('Un été brûlant sur la côte') ) @@ -865,13 +865,13 @@ class String extends Test\Unit\Suite { ->isInstanceOf('Hoa\String\Exception'); } - public function case_to_ascii_no_normalizer_try ( ) { + public function case_to_ascii_no_transliterator_no_normalizer_try ( ) { $this ->given( $this->function->class_exists = function ( $name ) { - return 'Normalizer' !== $name; + return false === in_array($name, ['Transliterator', 'Normalizer']); }, $string = new LUT('Un été brûlant sur la côte') ) @@ -883,10 +883,16 @@ class String extends Test\Unit\Suite { ->isEqualTo('Un ete brulant sur la cote'); } - public function case_to_ascii ( ) { + public function case_to_ascii_no_transliterator ( ) { $this - ->given($string = new LUT('Un été brûlant sur la côte')) + ->given( + $this->function->class_exists = function ( $name ) { + + return 'Transliterator' !== $name; + }, + $string = new LUT('Un été brûlant sur la côte') + ) ->when($result = $string->toAscii()) ->then ->object($result) @@ -895,6 +901,56 @@ class String extends Test\Unit\Suite { ->isEqualTo('Un ete brulant sur la cote'); } + public function case_to_ascii ( ) { + + $this + ->given( + $strings = [ + 'Un été brûlant sur la côte' + => 'Un ete brulant sur la cote', + + 'Αυτή είναι μια δοκιμή' + => 'Aute einai mia dokime', + + 'أحبك' + => 'ahbk', + + 'رابتخالا وه اذه' + => 'rabtkhala wh adhh', + + 'キャンパス' + => 'kyanpasu', + + 'биологическом' + => 'biologiceskom', + + '정, 병호' + => 'jeong, byeongho', + + 'ますだ, よしひこ' + => 'masuda, yoshihiko', + + 'मोनिच' + => 'monica', + + 'क्ष' + => 'ksa' + ] + ) + ->when(function ( ) use ( $strings ) { + + foreach($strings as $original => $asciied) + $this + ->given($string = new LUT($original)) + ->when($result = $string->toAscii()) + ->then + ->object($result) + ->isIdenticalTo($string) + ->string((string) $result) + ->isEqualTo($asciied); + }); + } + public function case_copy ( ) { $this |