Skip to content

Commit 13c0e24

Browse files
committed
Merge branch 'release/1.1.0'
2 parents f7f5566 + a50b88b commit 13c0e24

File tree

7 files changed

+144
-4
lines changed

7 files changed

+144
-4
lines changed

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,3 +11,4 @@ Homestead.yaml
1111
npm-debug.log
1212
yarn-error.log
1313
.env
14+
.phpunit.result.cache

.travis.yml

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
language: php
2+
3+
php:
4+
- 7.1
5+
6+
before_script: composer install
7+
8+
script: ./vendor/bin/phpunit

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.0.10",
3+
"version": "1.1.0",
44
"description": "Prettify PHPUnit output",
55
"type": "library",
66
"license": "MIT",

phpunit.xml

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
<?xml version="1.0" encoding="UTF-8"?>
2+
<phpunit backupGlobals="false"
3+
backupStaticAttributes="false"
4+
bootstrap="vendor/autoload.php"
5+
colors="true"
6+
printerClass="Sempro\PHPUnitPrettyPrinter\PrettyPrinter"
7+
convertErrorsToExceptions="true"
8+
convertNoticesToExceptions="true"
9+
convertWarningsToExceptions="true"
10+
processIsolation="false"
11+
stopOnFailure="false">
12+
<testsuites>
13+
<testsuite name="Test suite">
14+
<directory suffix="Test.php">./tests</directory>
15+
</testsuite>
16+
</testsuites>
17+
<php>
18+
<env name="APP_ENV" value="testing"/>
19+
</php>
20+
</phpunit>

src/PrettyPrinter.php

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -31,9 +31,9 @@ public function endTest(Test $test, float $time): void
3131

3232
$testMethodName = \PHPUnit\Util\Test::describe($test);
3333

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

@@ -44,7 +44,7 @@ public function endTest(Test $test, float $time): void
4444

4545
$name = implode(' ', $testNameArray);
4646

47-
// get the data set name
47+
// Get the data set name
4848
$name = $this->handleDataSetName($name, $testMethodName[1]);
4949

5050
$color = 'fg-green';

tests/Output.php

Lines changed: 43 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,43 @@
1+
<?php
2+
3+
namespace Sempro\PHPUnitPrettyPrinter\Tests;
4+
5+
use Exception;
6+
7+
class OutputTest extends \PHPUnit\Framework\TestCase
8+
{
9+
public function testSuccess(): void
10+
{
11+
$this->assertTrue(true);
12+
}
13+
14+
public function testFail(): void
15+
{
16+
$this->assertTrue(false);
17+
}
18+
19+
public function testError(): void
20+
{
21+
throw new Exception('error');
22+
}
23+
24+
public function testSkip(): void
25+
{
26+
$this->markTestSkipped('skipped');
27+
}
28+
29+
public function testIncomplete(): void
30+
{
31+
$this->markTestIncomplete('incomplete');
32+
}
33+
34+
public function testShouldConvertTitleCaseToLowercasedWords()
35+
{
36+
$this->assertTrue(true);
37+
}
38+
39+
public function test_should_convert_snake_case_to_lowercased_words()
40+
{
41+
$this->assertTrue(true);
42+
}
43+
}

tests/PrinterTest.php

Lines changed: 68 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,68 @@
1+
<?php
2+
3+
namespace Sempro\PHPUnitPrettyPrinter\Tests;
4+
5+
class PrinterTest extends \PHPUnit\Framework\TestCase
6+
{
7+
public function testFirstTestShouldPass()
8+
{
9+
$lines = $this->getOutput();
10+
11+
$this->assertStringContainsString('✓ success', $lines[4]);
12+
}
13+
14+
public function testSecondTestShouldFail()
15+
{
16+
$lines = $this->getOutput();
17+
18+
$this->assertStringContainsString('x fail', $lines[5]);
19+
}
20+
21+
public function testThirdTestShouldThrowAnError()
22+
{
23+
$lines = $this->getOutput();
24+
25+
$this->assertStringContainsString('⚈ error', $lines[6]);
26+
}
27+
28+
public function testForthTestShouldBeSkipped()
29+
{
30+
$lines = $this->getOutput();
31+
32+
$this->assertStringContainsString('→ skip', $lines[7]);
33+
}
34+
35+
public function testFifthTestShouldBeIncomplete()
36+
{
37+
$lines = $this->getOutput();
38+
39+
$this->assertStringContainsString('∅ incomplete', $lines[8]);
40+
}
41+
42+
public function testTestNamesCanBeTitleCased()
43+
{
44+
$lines = $this->getOutput();
45+
46+
$this->assertStringContainsString('✓ should convert title case to lowercased words', $lines[9]);
47+
}
48+
49+
public function testTestNameCanBeSnakeCased()
50+
{
51+
$lines = $this->getOutput();
52+
53+
$this->assertStringContainsString('✓ should convert snake case to lowercased words', $lines[10]);
54+
}
55+
56+
private function getOutput(): array
57+
{
58+
$command = [
59+
"vendor/bin/phpunit",
60+
"tests/Output.php",
61+
"--printer 'Sempro\PHPUnitPrettyPrinter\PrettyPrinter'",
62+
];
63+
64+
exec(implode(' ', $command), $out);
65+
66+
return $out;
67+
}
68+
}

0 commit comments

Comments
 (0)