Skip to content

Commit 07ddeba

Browse files
committed
Added PHPUnit 10 support (complete rewrite).
Renamed PHPUnit Immediate Exception Printer -> PHPUnit Immediate Printer. Dropped PHPUnit 5/6 support.
1 parent de2f8a0 commit 07ddeba

34 files changed

+637
-558
lines changed

README.md

Lines changed: 13 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,13 @@
1-
PHPUnit Immediate Exception Printer
2-
===================================
1+
PHPUnit Immediate Printer
2+
=========================
33

44
[![Latest version][Version image]][Releases]
55
[![Total downloads][Downloads image]][Downloads]
66
[![Build status][Build image]][Build]
77
[![Test coverage][Coverage image]][Coverage]
88
[![Code style][Style image]][Style]
99

10-
Immediate Exception Printer is a [PHPUnit][PHPUnit] plug-in that prints out exceptions and assertion failures immediately during a test run. Normally PHPUnit keeps error details secret until the end of the test run, but sometimes we don't want to wait that long. With Immediate Exception Printer, all secrets are immediately revealed, with a few extra benefits, too.
10+
PHPUnit Immediate Printer (Pip) is a [PHPUnit][] extension that prints exceptions and assertion failures immediately during a test run. Normally PHPUnit keeps failure details secret until the end of the test run, but sometimes we don't want to wait that long. With Pip, all secrets are immediately revealed, with a few extra benefits, too.
1111

1212
## Benefits
1313

@@ -28,31 +28,29 @@ This printer makes no attempt to modify the test summary; only runtime output is
2828

2929
1. Add the dependency to your Composer file's `require-dev` section.
3030

31-
```json
32-
"scriptfusion/phpunit-immediate-exception-printer": "^1"
31+
```bash
32+
composer require --dev scriptfusion/pip
3333
```
3434

35-
2. Declare the printer class in your [`phpunit.xml` configuration file](https://phpunit.de/manual/current/en/appendixes.configuration.html).
35+
2. Declare the printer class in your `phpunit.xml` configuration file.
3636

3737
```xml
38-
<phpunit
39-
printerClass="ScriptFUSION\PHPUnitImmediateExceptionPrinter\ImmediateExceptionPrinter"
40-
colors="true"
41-
>
38+
<extensions>
39+
<bootstrap class="ScriptFUSION\Pip\PipExtension"/>
40+
</extensions>
4241
```
4342

44-
3. Run the tests! If you didn't update `phpunit.xml` the same options can be specified on the command-line instead.
43+
3. Run the tests!
4544

4645
```bash
47-
vendor/bin/phpunit --printer 'ScriptFUSION\PHPUnitImmediateExceptionPrinter\ImmediateExceptionPrinter' --color
46+
vendor/bin/phpunit
4847
```
4948

5049
4. Enjoy immediate test execution feedback.
5150

5251
## Requirements
5352

54-
* PHP 5.6 or newer.
55-
* [PHPUnit][PHPUnit] 5.5 or newer.
53+
* [PHPUnit][] 10.
5654

5755
## Testing
5856

@@ -69,7 +67,7 @@ To test the output of a particular capability we run `CapabilitiesTest` with the
6967
One challenge we must overcome is verifying coloured output including ANSI escape sequences. To see these escape sequences we can pipe the output of a specific capability test to `cat -v` as shown in the following example.
7068

7169
```bash
72-
vendor/bin/phpunit -c test --colors=always test/CapabilitiesTest --filter ::testSuccess$ | cat -v
70+
vendor/bin/phpunit -c test --colors=always test/CapabilitiesTest.php --filter ::testSuccess$ | cat -v
7371
```
7472

7573
The output from `cat` will print the "escape" character as `^[`. We must replace each occurrence of this character sequence with the literal escape character (ASCII character 27). The easiest way to obtain the real escape character is to just copy it from an existing functional test.

composer.json

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,24 +1,24 @@
11
{
2-
"name": "scriptfusion/phpunit-immediate-exception-printer",
3-
"description": "Immediately prints exception and assertion failures during testing.",
2+
"name": "scriptfusion/pip",
3+
"description": "Immediately prints exceptions and assertion failures during testing.",
44
"authors": [
55
{
66
"name": "Bilge",
77
"email": "bilge@scriptfusion.com"
88
}
99
],
1010
"require": {
11-
"php": ">=5.6",
12-
"phpunit/phpunit": "^5.5|^6"
11+
"php": ">=8.1",
12+
"phpunit/phpunit": "^10.5.28"
1313
},
1414
"autoload": {
1515
"psr-4": {
16-
"ScriptFUSION\\PHPUnitImmediateExceptionPrinter\\": "src"
16+
"ScriptFUSION\\Pip\\": "src"
1717
}
1818
},
1919
"autoload-dev": {
2020
"psr-4": {
21-
"ScriptFUSIONTest\\PHPUnitImmediateExceptionPrinter\\": "test"
21+
"ScriptFUSIONTest\\Pip\\": "test"
2222
}
2323
},
2424
"scripts": {

src/ImmediateExceptionPrinter.php

Lines changed: 0 additions & 12 deletions
This file was deleted.

src/PhpUnit5Printer.php

Lines changed: 0 additions & 38 deletions
This file was deleted.

src/PhpUnit6Printer.php

Lines changed: 0 additions & 42 deletions
This file was deleted.

src/PipExtension.php

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
<?php
2+
declare(strict_types = 1);
3+
4+
namespace ScriptFUSION\Pip;
5+
6+
use PHPUnit\Runner\Extension\Extension;
7+
use PHPUnit\Runner\Extension\Facade;
8+
use PHPUnit\Runner\Extension\ParameterCollection;
9+
use PHPUnit\TextUI\Configuration\Configuration;
10+
11+
final class PipExtension implements Extension
12+
{
13+
public function bootstrap(Configuration $configuration, Facade $facade, ParameterCollection $parameters): void
14+
{
15+
$facade->registerTracer(new Printer());
16+
$facade->replaceProgressOutput();
17+
}
18+
}

0 commit comments

Comments
 (0)