Use mb_strlen instead of grapheme_strlen

Due to inconsistent behave, mb_strlen will be used.
This commit is contained in:
Daniel Ang
2021-08-29 12:55:37 +02:00
parent 851ce36010
commit 042f2ec3f3
3 changed files with 3 additions and 4 deletions

View File

@ -333,7 +333,7 @@ final class Expectation
public function toHaveLength(int $number): Expectation
{
if (is_string($this->value)) {
Assert::assertEquals($number, grapheme_strlen($this->value));
Assert::assertEquals($number, mb_strlen($this->value));
return $this;
}

View File

@ -423,7 +423,6 @@
✓ it passes with ('Fortaleza')
✓ it passes with ('Sollefteå')
✓ it passes with ('Ιεράπετρα')
✓ it passes with ('PT-BR 🇵🇹🇧🇷😎')
✓ it passes with (stdClass Object (...))
✓ it passes with (Illuminate\Support\Collection Object (...))
✓ it passes with array
@ -677,5 +676,5 @@
✓ it is a test
✓ it uses correct parent class
Tests: 4 incompleted, 9 skipped, 445 passed
Tests: 4 incompleted, 9 skipped, 444 passed

View File

@ -5,7 +5,7 @@ use PHPUnit\Framework\ExpectationFailedException;
it('passes', function ($value) {
expect($value)->toHaveLength(9);
})->with([
'Fortaleza', 'Sollefteå', 'Ιεράπετρα', 'PT-BR 🇵🇹🇧🇷😎',
'Fortaleza', 'Sollefteå', 'Ιεράπετρα',
(object) [1, 2, 3, 4, 5, 6, 7, 8, 9],
collect([1, 2, 3, 4, 5, 6, 7, 8, 9]),
]);