Skip to content

Commit

Permalink
Closes #2039
Browse files Browse the repository at this point in the history
  • Loading branch information
Sebastian Bergmann authored and Sebastian Bergmann committed Feb 23, 2016
1 parent 6e35126 commit 72bd997
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 11 deletions.
18 changes: 8 additions & 10 deletions src/Util/TestDox/NamePrettifier.php
Expand Up @@ -81,23 +81,21 @@ public function prettifyTestMethod($name)
$this->strings[] = $string;
}

if (strpos($name, '_') !== false) {
return str_replace('_', ' ', $name);
if (substr($name, 0, 4) == 'test') {
$name = substr($name, 4);
}

$max = strlen($name);
$name[0] = strtoupper($name[0]);

if (substr($name, 0, 4) == 'test') {
$offset = 4;
} else {
$offset = 0;
$name[0] = strtoupper($name[0]);
if (strpos($name, '_') !== false) {
return trim(str_replace('_', ' ', $name));
}

$max = strlen($name);
$wasNumeric = false;

for ($i = $offset; $i < $max; $i++) {
if ($i > $offset &&
for ($i = 0; $i < $max; $i++) {
if ($i > 0 &&
ord($name[$i]) >= 65 &&
ord($name[$i]) <= 90) {
$buffer .= ' ' . strtolower($name[$i]);
Expand Down
2 changes: 1 addition & 1 deletion tests/Util/TestDox/NamePrettifierTest.php
Expand Up @@ -64,7 +64,7 @@ public function testTestNameIsConvertedToASentence()
{
$this->assertEquals('This is a test', $this->namePrettifier->prettifyTestMethod('testThisIsATest'));
$this->assertEquals('This is a test', $this->namePrettifier->prettifyTestMethod('testThisIsATest2'));
$this->assertEquals('this is a test', $this->namePrettifier->prettifyTestMethod('this_is_a_test'));
$this->assertEquals('This is a test', $this->namePrettifier->prettifyTestMethod('this_is_a_test'));
$this->assertEquals('Foo for bar is 0', $this->namePrettifier->prettifyTestMethod('testFooForBarIs0'));
$this->assertEquals('Foo for baz is 1', $this->namePrettifier->prettifyTestMethod('testFooForBazIs1'));
}
Expand Down

0 comments on commit 72bd997

Please sign in to comment.