Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Make compatible with phpunit 7.x #41

Merged
merged 5 commits into from
Feb 24, 2018
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,12 +3,12 @@ language: php
sudo: false

php:
- 7.0
- 7.1
- 7.2
- nightly

env:
- PHPUNIT=6.0.*
- PHPUNIT=7.*

cache:
directories:
Expand Down
6 changes: 3 additions & 3 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,8 @@
}
],
"require": {
"php": ">=7.0",
"phpunit/phpunit": "^6.0"
"php": ">=7.1",
"phpunit/phpunit": "^7.0"

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@luispabon You could also support ^6.4|^7.0 with this.

Copy link
Contributor

@keradus keradus Feb 22, 2018

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

no you can't.
PHPUnit 6 doesn't have typehinting, PHPUnit 7 does, if you want to support both, you need to provide 2 versions of class and load one depends on PHPUnit version

Copy link
Contributor Author

@luispabon luispabon Feb 22, 2018

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

as keradus said it cannot be done due to interfaces being completely incompatible due to the newer php7.1 type hints. You would need two implementations, and that's what semver+composer already give us.

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ah yeah... totally overlooked the additional typehints in 7.0.

},
"autoload": {
"psr-4": {
Expand All @@ -27,7 +27,7 @@
},
"extra": {
"branch-alias": {
"dev-master": "2.0-dev"
"dev-master": "3.0-dev"
}
}
}
12 changes: 7 additions & 5 deletions src/SpeedTrapListener.php
Original file line number Diff line number Diff line change
Expand Up @@ -3,14 +3,16 @@

namespace JohnKary\PHPUnit\Listener;

use PHPUnit\Framework\{AssertionFailedError, TestSuite, Test, TestCase, BaseTestListener, Warning};
use PHPUnit\Framework\{TestListener, TestListenerDefaultImplementation, TestSuite, Test, TestCase};

/**
* A PHPUnit TestListener that exposes your slowest running tests by outputting
* results directly to the console.
*/
class SpeedTrapListener extends BaseTestListener
class SpeedTrapListener implements TestListener
{
use TestListenerDefaultImplementation;

/**
* Internal tracking for test suites.
*
Expand Down Expand Up @@ -52,7 +54,7 @@ public function __construct(array $options = [])
* @param Test $test
* @param float $time
*/
public function endTest(Test $test, $time)
public function endTest(Test $test, float $time): void
{
if (!$test instanceof TestCase) return;

Expand All @@ -69,7 +71,7 @@ public function endTest(Test $test, $time)
*
* @param TestSuite $suite
*/
public function startTestSuite(TestSuite $suite)
public function startTestSuite(TestSuite $suite): void
{
$this->suites++;
}
Expand All @@ -79,7 +81,7 @@ public function startTestSuite(TestSuite $suite)
*
* @param TestSuite $suite
*/
public function endTestSuite(TestSuite $suite)
public function endTestSuite(TestSuite $suite): void
{
$this->suites--;

Expand Down