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 22, 2016
1 parent 8a509b2 commit 7467a57
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 11 deletions.
7 changes: 7 additions & 0 deletions ChangeLog-5.2.md
Expand Up @@ -2,6 +2,12 @@

All notable changes of the PHPUnit 5.2 release series are documented in this file using the [Keep a CHANGELOG](http://keepachangelog.com/) principles.

## [5.2.10] - 2016-MM-DD

### Fixed

* Fixed [#2039](https://github.com/sebastianbergmann/phpunit/issues/2039): TestDox does not handle snake_case test methods properly

## [5.2.9] - 2016-02-19

### Changed
Expand Down Expand Up @@ -80,6 +86,7 @@ All notable changes of the PHPUnit 5.2 release series are documented in this fil

* The `mapTestClassNameToCoveredClassName` configuration setting has been removed

[5.2.10]: https://github.com/sebastianbergmann/phpunit/compare/5.2.9...5.2.10
[5.2.9]: https://github.com/sebastianbergmann/phpunit/compare/5.2.8...5.2.9
[5.2.8]: https://github.com/sebastianbergmann/phpunit/compare/5.2.7...5.2.8
[5.2.7]: https://github.com/sebastianbergmann/phpunit/compare/5.2.6...5.2.7
Expand Down
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 7467a57

Please sign in to comment.