Skip to content

Commit 8c70010

Browse files
committed
Merge branch 'release/1.1.11'
2 parents 7449efe + b6cb470 commit 8c70010

File tree

4 files changed

+35
-9
lines changed

4 files changed

+35
-9
lines changed

composer.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "sempro/phpunit-pretty-print",
3-
"version": "1.1.10",
3+
"version": "1.1.11",
44
"description": "Prettify PHPUnit output",
55
"type": "library",
66
"license": "MIT",

src/PrettyPrinter.php

Lines changed: 10 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -33,20 +33,22 @@ public function endTest(Test $test, float $time): void
3333

3434
// Convert non-breaking method name to camelCase
3535
$testMethodName[1] = str_replace(' ', '', ucwords($testMethodName[1], ' '));
36-
36+
3737
// Convert snakeCase method name to camelCase
3838
$testMethodName[1] = str_replace('_', '', ucwords($testMethodName[1], '_'));
39-
40-
preg_match_all('/((?:^|[A-Z])[a-z]+)/', $testMethodName[1], $matches);
41-
$testNameArray = array_map('strtolower', $matches[0]);
4239

43-
// check if prefix is test remove it
44-
if ($testNameArray[0] === 'test') {
45-
array_shift($testNameArray);
46-
}
40+
preg_match_all('/((?:^|[A-Z])[a-z0-9]+)/', $testMethodName[1], $matches);
41+
42+
// Prepend all numbers with a space
43+
$replaced = preg_replace('/(\d+)/', ' $1', $matches[0]);
44+
45+
$testNameArray = array_map('strtolower', $replaced);
4746

4847
$name = implode(' ', $testNameArray);
4948

49+
// check if prefix is test remove it
50+
$name = preg_replace('/^test /', '', $name, 1);
51+
5052
// Get the data set name
5153
$name = $this->handleDataSetName($name, $testMethodName[1]);
5254

tests/Output.php

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -45,4 +45,14 @@ public function test should convert non breaking spaces to lowercased wo
4545
{
4646
$this->assertTrue(true);
4747
}
48+
49+
public function testCanContain1Or99Numbers()
50+
{
51+
$this->assertTrue(true);
52+
}
53+
54+
public function test123CanStartOrEndWithNumbers456()
55+
{
56+
$this->assertTrue(true);
57+
}
4858
}

tests/PrinterTest.php

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -60,6 +60,20 @@ public function testTestNameCanBeNonBreakingSpaced()
6060
$this->assertStringContainsString('✓ should convert non breaking spaces to lowercased words', $lines[11]);
6161
}
6262

63+
public function testTestNameCanContainNumbers()
64+
{
65+
$lines = $this->getOutput();
66+
67+
$this->assertStringContainsString('✓ can contain 1 or 99 numbers', $lines[12]);
68+
}
69+
70+
public function testTestNameCanStartOrEndWithANumber()
71+
{
72+
$lines = $this->getOutput();
73+
74+
$this->assertStringContainsString('✓ 123 can start or end with numbers 456', $lines[13]);
75+
}
76+
6377
private function getOutput(): array
6478
{
6579
$command = [

0 commit comments

Comments
 (0)