Skip to content
Permalink
Browse files

Closes #3741

  • Loading branch information...
sebastianbergmann committed Jul 30, 2019
1 parent 1c015f5 commit 74d84f7a5a5563667547e6e76eeb13ab3dbc6eea
@@ -6,6 +6,7 @@ All notable changes of the PHPUnit 8.3 release series are documented in this fil

### Added

* Implemented [#3741](https://github.com/sebastianbergmann/phpunit/issues/3741): Format class names as well as method names in testdox output
* Implemented [#3748](https://github.com/sebastianbergmann/phpunit/issues/3748): Add option to sort tests based on information from `@small`, `@medium`, and `@large`
* Added `TestCase::getActualOutputForAssertion()` as a wrapper for `TestCase::getActualOutput()` to prevent a test being marked as risky when it prints output and that output is not expected using `TestCase::expectOutputString()` or `TestCase::expectOutputRegEx()`

@@ -49,20 +49,47 @@ public function prettifyTestClass(string $className): string
} catch (UtilException $e) {
}
$result = $className;
$parts = \explode('\\', $className);
$className = \array_pop($parts);
if (\substr($className, -1 * \strlen('Test')) === 'Test') {
$result = \substr($result, 0, \strripos($result, 'Test'));
$className = \substr($className, 0, \strlen($className) - \strlen('Test'));
}
if (\strpos($className, 'Tests') === 0) {
$result = \substr($result, \strlen('Tests'));
$className = \substr($className, \strlen('Tests'));
} elseif (\strpos($className, 'Test') === 0) {
$result = \substr($result, \strlen('Test'));
$className = \substr($className, \strlen('Test'));
}
if ($result[0] === '\\') {
$result = \substr($result, 1);
if (!empty($parts)) {
$parts[] = $className;
$fullyQualifiedName = \implode('\\', $parts);
} else {
$fullyQualifiedName = $className;
}
$result = '';
$wasLowerCase = false;
foreach (\range(0, \strlen($className) - 1) as $i) {
$isLowerCase = \mb_strtolower($className[$i], 'UTF-8') === $className[$i];
if ($wasLowerCase && !$isLowerCase) {
$result .= ' ';
}
$result .= $className[$i];
if ($isLowerCase) {
$wasLowerCase = true;
} else {
$wasLowerCase = false;
}
}
if ($fullyQualifiedName !== $className) {
return $result . ' (' . $fullyQualifiedName . ')';
}
return $result;
@@ -153,10 +180,9 @@ public function prettifyTestMethod(string $name): string
return \trim(\str_replace('_', ' ', $name));
}
$max = \strlen($name);
$wasNumeric = false;
for ($i = 0; $i < $max; $i++) {
foreach (\range(0, \strlen($name) - 1) as $i) {
if ($i > 0 && \ord($name[$i]) >= 65 && \ord($name[$i]) <= 90) {
$buffer .= ' ' . \strtolower($name[$i]);
} else {
@@ -13,7 +13,7 @@ PHPUnit\TextUI\Command::main();
--EXPECTF--
PHPUnit %s by Sebastian Bergmann and contributors.
DummyFoo
Dummy Foo
Foo equals foo
Time: %s, Memory: %s
@@ -11,7 +11,7 @@ PHPUnit\TextUI\Command::main();
--EXPECTF--
PHPUnit %s by Sebastian Bergmann and contributors.
DummyBar
Dummy Bar
Bar equals bar
Time: %s, Memory: %s
@@ -14,7 +14,7 @@ PHPUnit\TextUI\Command::main();
--EXPECTF--
PHPUnit %s by Sebastian Bergmann and contributors.
NumericGroupAnnotation
Numeric Group Annotation
Empty test for @ticket numeric annotation values
Empty test for @group numeric annotation values
@@ -3,7 +3,7 @@ PHPUnit %s Sebastian Bergmann and contributors.
Runtime: %s
Configuration: %stests%ebasic%econfiguration.basic.xml

PHPUnit\SelfTest\Basic\SetUpBeforeClass
Set Up Before Class (PHPUnit\SelfTest\Basic\SetUpBeforeClass)
✘ One  %f ms
┐
├ Exception: forcing an Exception in setUpBeforeClass()
@@ -18,7 +18,7 @@ Configuration: %stests%ebasic%econfiguration.basic.xml
╵ %stests%ebasic%eunit%eSetUpBeforeClassTest.php:31
┴

PHPUnit\SelfTest\Basic\SetUp
Set Up (PHPUnit\SelfTest\Basic\SetUp)
✘ One with set up exception  %f ms
┐
├ RuntimeException: throw exception in setUp
@@ -115,7 +115,7 @@ Configuration: %stests%ebasic%econfiguration.basic.xml
╵ %stests%ebasic%eunit%eStatusTest.php:%d
┴

PHPUnit\SelfTest\Basic\TearDownAfterClass
Tear Down After Class (PHPUnit\SelfTest\Basic\TearDownAfterClass)
✔ One  %f ms
✔ Two  %f ms
✘ Tear down after class  0 ms
@@ -18,7 +18,7 @@ PHPUnit\TextUI\Command::main();
--EXPECTF--
PHPUnit %s by Sebastian Bergmann and contributors.
.DoxGroup
.Dox Group
. 2 / 2 (100%) [x] Two
@@ -18,7 +18,7 @@ PHPUnit\TextUI\Command::main();
--EXPECTF--
PHPUnit %s by Sebastian Bergmann and contributors.
DoxGroup
Dox Group
.. 2 / 2 (100%) [x] One
@@ -46,7 +46,7 @@ PHPUnit %s by Sebastian Bergmann and contributors.
</head>
<body>
<h2 id="BankAccountTest">BankAccount</h2>
<h2 id="BankAccountTest">Bank Account</h2>
<ul>
... 3 / 3 (100%) <li style="color: #555753;">Balance is initially zero</li>
<li style="color: #555753;">Balance cannot become negative</li>
@@ -16,7 +16,7 @@ PHPUnit\TextUI\Command::main();
--EXPECTF--
PHPUnit %s by Sebastian Bergmann and contributors.
BankAccount
Bank Account
... 3 / 3 (100%) [x] Balance is initially zero
[x] Balance cannot become negative
[x] Balance cannot become negative
@@ -19,7 +19,7 @@ unlink($tmpResultCache);
--EXPECTF--
PHPUnit %s by Sebastian Bergmann and contributors.
DataproviderExecutionOrder
Dataprovider Execution Order
First test that always works
Add numbers with a dataprovider with data set "1+2=3"
Add numbers with a dataprovider with data set "2+1=3"
@@ -44,7 +44,7 @@ Time: %s, Memory: %s
Summary of non-successful tests:
DataproviderExecutionOrder
Dataprovider Execution Order
Add numbers with a dataprovider with data set "1+1=3"
Failed asserting that 2 is identical to 3.
@@ -47,7 +47,7 @@ public function testPrintsTheClassNameOfTheTestClass(): void
$this->printer->startTest($this);
$this->printer->endTest($this, 0);
$this->assertStringStartsWith('PHPUnit\Util\TestDox\CliTestDoxPrinter', $this->printer->getBuffer());
$this->assertStringStartsWith('Cli Test Dox Printer (PHPUnit\Util\TestDox\CliTestDoxPrinter)', $this->printer->getBuffer());
}
public function testPrintsThePrettifiedMethodName(): void
@@ -37,8 +37,8 @@ public function testTitleHasSensibleDefaults(): void
$this->assertEquals('Foo', $this->namePrettifier->prettifyTestClass('FooTest'));
$this->assertEquals('Foo', $this->namePrettifier->prettifyTestClass('TestFoo'));
$this->assertEquals('Foo', $this->namePrettifier->prettifyTestClass('TestFooTest'));
$this->assertEquals('Foo', $this->namePrettifier->prettifyTestClass('Test\FooTest'));
$this->assertEquals('Foo', $this->namePrettifier->prettifyTestClass('Tests\FooTest'));
$this->assertEquals('Foo (Test\Foo)', $this->namePrettifier->prettifyTestClass('Test\FooTest'));
$this->assertEquals('Foo (Tests\Foo)', $this->namePrettifier->prettifyTestClass('Tests\FooTest'));
}
public function testTestNameIsConvertedToASentence(): void

0 comments on commit 74d84f7

Please sign in to comment.
You can’t perform that action at this time.