Skip to content

Commit

Permalink
Merge branch 'master' of github.com:Codeception/Codeception
Browse files Browse the repository at this point in the history
  • Loading branch information
DavertMik committed Mar 1, 2016
2 parents 9e3818d + 8cfbe9b commit fd36780
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 3 deletions.
6 changes: 3 additions & 3 deletions src/Codeception/Step.php
Original file line number Diff line number Diff line change
Expand Up @@ -100,14 +100,14 @@ public function getArgumentsAsString($maxLength = 200)
foreach ($arguments as $key => $argument) {
$stringifiedArgument = $this->stringifyArgument($argument);
$arguments[$key] = $stringifiedArgument;
$totalLength += strlen($stringifiedArgument);
$totalLength += mb_strlen($stringifiedArgument, 'utf-8');
}

if ($totalLength > $maxLength) {
//sort arguments from shortest to longest
uasort($arguments, function($arg1, $arg2) {
$length1 = strlen($arg1);
$length2 = strlen($arg2);
$length1 = mb_strlen($arg1, 'utf-8');
$length2 = mb_strlen($arg2, 'utf-8');
if ($length1 === $length2) {
return 0;
}
Expand Down
7 changes: 7 additions & 0 deletions tests/unit/Codeception/StepTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -82,4 +82,11 @@ public function testSeeUppercaseText()
$output = $step->toString(200);
$this->assertEquals('see "UPPER CASE"', $output);
}

public function testMultiByteTextLengthIsMeasuredCorrectly()
{
$step = $this->getStep(['see', ['ŽŽŽŽŽŽŽŽŽŽ', 'AAAAAAAAAAA']]);
$output = $step->toString(30);
$this->assertEquals('see "ŽŽŽŽŽŽŽŽŽŽ","AAAAAAAAAAA"', $output);
}
}

0 comments on commit fd36780

Please sign in to comment.