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

[PHPUnit 9.0] Add TestListenerToHooksRector #1270

Merged
merged 1 commit into from Mar 31, 2019

Conversation

1 participant
@TomasVotruba
Copy link
Member

commented Mar 27, 2019

Closes #1266

Migration path for sebastianbergmann/phpunit#3389

How to apply?

composer require rector/rector --dev
vendor/bin/rector process tests --level phpunit90

Showcase

 <?php

 namespace App\Tests;

-use PHPUnit\Framework\TestListener;
-
-final class BeforeListHook implements TestListener
+final class BeforeListHook implements \PHPUnit\Runner\BeforeTestHook, \PHPUnit\Runner\AfterTestHook
 {
-    public function addError(Test $test, \Throwable $t, float $time): void
-    {
-    }
-
-    public function addWarning(Test $test, Warning $e, float $time): void
-    {
-    }
-
-    public function addFailure(Test $test, AssertionFailedError $e, float $time): void
-    {
-    }
-
-    public function addIncompleteTest(Test $test, \Throwable $t, float $time): void
-    {
-    }
-
-    public function addRiskyTest(Test $test, \Throwable $t, float $time): void
-    {
-    }
-
-    public function addSkippedTest(Test $test, \Throwable $t, float $time): void
-    {
-    }
-
-    public function startTestSuite(TestSuite $suite): void
-    {
-    }
-
-    public function endTestSuite(TestSuite $suite): void
-    {
-    }

-    public function startTest(Test $test): void
+    public function executeBeforeTest(Test $test): void
     {
         echo 'start test!';
     }

-    public function endTest(Test $test, float $time): void
+    public function executeAfterTest(Test $test, float $time): void
     {
         echo $time;
     }
 }

@TomasVotruba TomasVotruba force-pushed the listener-hook branch 2 times, most recently from e619987 to fe8ab2e Mar 27, 2019

@TomasVotruba TomasVotruba force-pushed the listener-hook branch from fe8ab2e to 1e24821 Mar 31, 2019

@TomasVotruba TomasVotruba merged commit 44ee91f into master Mar 31, 2019

1 check was pending

continuous-integration/travis-ci/pr The Travis CI build is in progress
Details

@TomasVotruba TomasVotruba deleted the listener-hook branch Mar 31, 2019

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.