Skip to content

Commit 98900be

Browse files
committed
Added "test.name.strip" config option.
1 parent c7f4257 commit 98900be

File tree

6 files changed

+40
-6
lines changed

6 files changed

+40
-6
lines changed

README.md

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -55,10 +55,11 @@ Pip makes no attempt to modify the test summary; only runtime output is changed.
5555

5656
Pip's behaviour can be customized by adding `<parameter>` nodes as children of the `<bootstrap>` node in `phpunit.xml`, with `name` and `value` attributes corresponding to the table below.
5757
58-
| Parameter name | Default value | Description |
59-
|----------------|---------------|------------------------------------------------------------|
60-
| perf.slow | 200 (ms) | Sets the performance threshold for _slow_ (yellow) tests |
61-
| perf.vslow | 1000 (ms) | Sets the performance threshold for _very slow_ (red) tests |
58+
| Parameter name | Default value | Description |
59+
|-----------------|---------------|------------------------------------------------------------|
60+
| perf.slow | 200 (ms) | Sets the performance threshold for _slow_ (yellow) tests |
61+
| perf.vslow | 1000 (ms) | Sets the performance threshold for _very slow_ (red) tests |
62+
| test.name.strip | '' | Strips the specified matching portion of the test name |
6263
6364
## Requirements
6465

src/PipConfig.php

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@
55

66
final class PipConfig
77
{
8-
public int $perfSlow = 200;
9-
public int $perfVslow = 1_000;
8+
public int $perfSlow = 200;
9+
public int $perfVslow = 1_000;
10+
public string $testNameStrip = '';
1011
}

src/PipExtension.php

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@ public function bootstrap(Configuration $configuration, Facade $facade, Paramete
1515
$config = new PipConfig();
1616
$parameters->has('perf.slow') && $config->perfSlow = +$parameters->get('perf.slow');
1717
$parameters->has('perf.vslow') && $config->perfVslow = +$parameters->get('perf.vslow');
18+
$parameters->has('test.name.strip') && $config->testNameStrip = $parameters->get('test.name.strip');
1819

1920
$facade->registerTracer(new Printer($config));
2021
$facade->replaceProgressOutput();

src/Printer.php

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -95,6 +95,9 @@ public function trace(Event $event): void
9595

9696
if ($event instanceof Finished) {
9797
$id = $event->test()->id();
98+
if ($this->config->testNameStrip !== '') {
99+
$id = str_replace($this->config->testNameStrip, '', $id);
100+
}
98101

99102
// Data provider case.
100103
if ($event->test()->isTestMethod() && $event->test()->testData()->hasDataFromDataProvider()) {

test/config/TestNameStrip.xml

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
<phpunit>
2+
<extensions>
3+
<bootstrap class="ScriptFUSION\Pip\PipExtension">
4+
<parameter name="test.name.strip" value="ScriptFUSIONTest\Pip\"/>
5+
</bootstrap>
6+
</extensions>
7+
</phpunit>

test/config/test name strip.phpt

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
--TEST--
2+
Tests that when "test name strip" is specified, the matching portion of the test name is stripped from the output.
3+
4+
--ARGS--
5+
-c test/config/TestNameStrip.xml --colors=always test/CapabilitiesTest.php --filter ::testSuccess$
6+
7+
--FILE_EXTERNAL--
8+
../PHPUnit runner.php
9+
10+
--EXPECTF--
11+
PHPUnit %s
12+
13+
Runtime: %s
14+
Configuration: %s
15+
16+
100% . CapabilitiesTest::testSuccess (%d ms)
17+
18+
19+
Time: %s
20+
21+
OK (1 test, 1 assertion)

0 commit comments

Comments
 (0)