Skip to content

Commit 8c280ee

Browse files
committed
Change namespace from JohnKary\PHPUnit\Listener to JohnKary\PHPUnit\Extension
1 parent c452ff8 commit 8c280ee

File tree

7 files changed

+27
-43
lines changed

7 files changed

+27
-43
lines changed

CHANGELOG.md

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -18,10 +18,6 @@ Version 3.3 adds supports for PHPUnit 9.5+, and a way to enable or disable the S
1818
* [PR #73](https://github.com/johnkary/phpunit-speedtrap/pull/73) Compatibility with PHPUnit 9.5
1919
* [PR #66](https://github.com/johnkary/phpunit-speedtrap/pull/66) Environment variable PHPUNIT_SPEEDTRAP="disabled" can disable profiling
2020

21-
## Master
22-
23-
* [PR #67](https://github.com/johnkary/phpunit-speedtrap/pull/67) Handle deprecated TestListener in PHPUnit 8
24-
2521
## 3.2.0 (2020-02-12)
2622

2723
Version 3.2 introduces supports for PHPUnit 9.0+.

README.md

Lines changed: 16 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -20,27 +20,15 @@ SpeedTrap is installed using [Composer](http://getcomposer.org). Add it as a `re
2020
## Usage
2121

2222
Enable with all defaults by adding the following code to your project's `phpunit.xml` file:
23-
24-
If you are using PHPUnit 8 or above, and phpunit-speedtrap >= 4.0.0, you should register the listener like this:
2523

2624
```xml
2725
<phpunit bootstrap="vendor/autoload.php">
2826
...
2927
<extensions>
30-
<extension class="JohnKary\PHPUnit\Listener\SpeedTrapListener" />
28+
<extension class="JohnKary\PHPUnit\Extension\SpeedTrap" />
3129
</extensions>
3230
</phpunit>
3331
```
34-
Otherwise you can add the following:
35-
36-
```xml
37-
<phpunit bootstrap="vendor/autoload.php">
38-
...
39-
<listeners>
40-
<listener class="JohnKary\PHPUnit\Listener\SpeedTrapListener" />
41-
</listeners>
42-
</phpunit>
43-
```
4432

4533
Now run the test suite. If one or more test executions exceed the slowness threshold (500ms by default), SpeedTrap will report on those tests in the console after all tests have completed.
4634

@@ -58,7 +46,7 @@ Each parameter is set in `phpunit.xml`:
5846
<!-- ... other suite configuration here ... -->
5947

6048
<extensions>
61-
<extension class="JohnKary\PHPUnit\Listener\SpeedTrapListener">
49+
<extension class="JohnKary\PHPUnit\Extension\SpeedTrap">
6250
<arguments>
6351
<array>
6452
<element key="slowThreshold">
@@ -95,15 +83,15 @@ class SomeTestCase extends PHPUnit\Framework\TestCase
9583

9684
## Disable slowness profiling using an environment variable
9785

98-
SpeedTrapListener profiles for slow tests when enabled in phpunit.xml. But using an environment variable named `PHPUNIT_SPEEDTRAP` can enable or disable the listener.
86+
SpeedTrap profiles for slow tests when enabled in phpunit.xml. But using an environment variable named `PHPUNIT_SPEEDTRAP` can enable or disable the extension:
9987

10088
$ PHPUNIT_SPEEDTRAP="disabled" ./vendor/bin/phpunit
10189

10290
#### Use case: Disable profiling in development, but profile with Travis CI
10391

10492
Travis CI is popular for running tests in the cloud after pushing new code to a repository.
10593

106-
Step 1) Enable SpeedTrapListener in phpunit.xml, but set `PHPUNIT_SPEEDTRAP="disabled"` to disable profiling when running tests.
94+
Step 1) Enable SpeedTrap in phpunit.xml, but set `PHPUNIT_SPEEDTRAP="disabled"` to disable profiling when running tests.
10795

10896
```xml
10997
<phpunit bootstrap="vendor/autoload.php">
@@ -112,9 +100,9 @@ Step 1) Enable SpeedTrapListener in phpunit.xml, but set `PHPUNIT_SPEEDTRAP="dis
112100
<env name="PHPUNIT_SPEEDTRAP" value="disabled" />
113101
</php>
114102

115-
<listeners>
116-
<listener class="JohnKary\PHPUnit\Listener\SpeedTrapListener" />
117-
</listeners>
103+
<extensions>
104+
<extension class="JohnKary\PHPUnit\Extension\SpeedTrap" />
105+
</extensions>
118106
</phpunit>
119107
```
120108

@@ -136,14 +124,14 @@ Step 3) View the Travis CI build output and read the slowness report printed in
136124
137125
#### Use case: Enable profiling in development, but disable with Travis CI
138126
139-
Step 1) Enable SpeedTrapListener in phpunit.xml. The slowness report will output during all test suite executions.
127+
Step 1) Enable SpeedTrap in phpunit.xml. The slowness report will output during all test suite executions.
140128
141129
```xml
142130
<phpunit bootstrap="vendor/autoload.php">
143131
...
144-
<listeners>
145-
<listener class="JohnKary\PHPUnit\Listener\SpeedTrapListener" />
146-
</listeners>
132+
<extensions>
133+
<extension class="JohnKary\PHPUnit\Extension\SpeedTrap" />
134+
</extensions>
147135
</phpunit>
148136
```
149137

@@ -161,11 +149,11 @@ env:
161149
162150
Step 3) View the Travis CI build output and confirm the slowness report is not printed in the console.
163151
164-
#### Use case: Only enable SpeedTrapListener on demand via command-line
152+
#### Use case: Only enable SpeedTrap on demand via command-line
165153
166154
Useful when you only want to profile slow tests once in a while.
167155
168-
Step 1) Setup phpunit.xml to enable SpeedTrapListener, but disable slowness profiling by setting `PHPUNIT_SPEEDTRAP="disabled"` like this:
156+
Step 1) Setup phpunit.xml to enable SpeedTrap, but disable slowness profiling by setting `PHPUNIT_SPEEDTRAP="disabled"` like this:
169157

170158
```xml
171159
<phpunit bootstrap="vendor/autoload.php">
@@ -174,9 +162,9 @@ Step 1) Setup phpunit.xml to enable SpeedTrapListener, but disable slowness prof
174162
<env name="PHPUNIT_SPEEDTRAP" value="disabled" />
175163
</php>
176164
177-
<listeners>
178-
<listener class="JohnKary\PHPUnit\Listener\SpeedTrapListener" />
179-
</listeners>
165+
<extensions>
166+
<extension class="JohnKary\PHPUnit\Extension\SpeedTrap" />
167+
</extensions>
180168
</phpunit>
181169
```
182170

composer.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -26,12 +26,12 @@
2626
},
2727
"autoload": {
2828
"psr-4": {
29-
"JohnKary\\PHPUnit\\Listener\\": "src/"
29+
"JohnKary\\PHPUnit\\Extension\\": "src/"
3030
}
3131
},
3232
"autoload-dev": {
3333
"psr-4": {
34-
"JohnKary\\PHPUnit\\Listener\\Tests\\": "tests/"
34+
"JohnKary\\PHPUnit\\Extension\\Tests\\": "tests/"
3535
}
3636
}
3737
}

phpunit.xml.dist

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@
2121
</testsuites>
2222

2323
<extensions>
24-
<extension class="JohnKary\PHPUnit\Listener\SpeedTrapListener">
24+
<extension class="JohnKary\PHPUnit\Extension\SpeedTrap">
2525
<arguments>
2626
<array>
2727
<element key="slowThreshold">

src/SpeedTrapListener.php renamed to src/SpeedTrap.php

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,18 +1,18 @@
11
<?php
22
declare(strict_types=1);
33

4-
namespace JohnKary\PHPUnit\Listener;
4+
namespace JohnKary\PHPUnit\Extension;
55

66
use PHPUnit\Runner\AfterLastTestHook;
77
use PHPUnit\Runner\AfterSuccessfulTestHook;
88
use PHPUnit\Runner\BeforeFirstTestHook;
99
use PHPUnit\Util\Test as TestUtil;
1010

1111
/**
12-
* A PHPUnit TestHook that exposes your slowest running tests by outputting
12+
* A PHPUnit Extension that exposes your slowest running tests by outputting
1313
* results directly to the console.
1414
*/
15-
class SpeedTrapListener implements AfterSuccessfulTestHook, BeforeFirstTestHook, AfterLastTestHook
15+
class SpeedTrap implements AfterSuccessfulTestHook, BeforeFirstTestHook, AfterLastTestHook
1616
{
1717
/**
1818
* Slowness profiling enabled by default. Set to false to disable profiling
@@ -149,7 +149,7 @@ protected function toMilliseconds(float $time): int
149149
* Label describing a slow test case. Formatted to support copy/paste with
150150
* PHPUnit's --filter CLI option:
151151
*
152-
* vendor/bin/phpunit --filter 'JohnKary\\PHPUnit\\Listener\\Tests\\SomeSlowTest::testWithDataProvider with data set "Rock"'
152+
* vendor/bin/phpunit --filter 'JohnKary\\PHPUnit\\Extension\\Tests\\SomeSlowTest::testWithDataProvider with data set "Rock"'
153153
*/
154154
protected function makeLabel(string $test): string
155155
{

tests/ExceptionalTest.php

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
<?php
22
declare(strict_types=1);
33

4-
namespace JohnKary\PHPUnit\Listener\Tests;
4+
namespace JohnKary\PHPUnit\Extension\Tests;
55

66
use PHPUnit\Framework\TestCase;
77

@@ -16,12 +16,12 @@ public function testExceptionCanBeThrownInTest()
1616

1717
public function testSkippedTest()
1818
{
19-
$this->markTestSkipped('Skipped tests do not cause Exceptions in Listener');
19+
$this->markTestSkipped('Skipped tests do not cause Exceptions in SpeedTrap extension');
2020
}
2121

2222
public function testIncompleteTest()
2323
{
24-
$this->markTestIncomplete('Incomplete tests do not cause Exceptions in Listener');
24+
$this->markTestIncomplete('Incomplete tests do not cause Exceptions in SpeedTrap extension');
2525
}
2626
}
2727

tests/SomeSlowTest.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
<?php
22
declare(strict_types=1);
33

4-
namespace JohnKary\PHPUnit\Listener\Tests;
4+
namespace JohnKary\PHPUnit\Extension\Tests;
55

66
use PHPUnit\Framework\TestCase;
77

0 commit comments

Comments
 (0)