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

Deprecation issues with phpunit 8 #1024

Open
rbaarsma opened this issue Nov 25, 2019 · 9 comments
Open

Deprecation issues with phpunit 8 #1024

rbaarsma opened this issue Nov 25, 2019 · 9 comments

Comments

@rbaarsma
Copy link

  1x: The "Mockery\Adapter\Phpunit\Legacy\TestListenerForV7" class implements "PHPUnit\Framework\TestListener" that is deprecated Use the `TestHook` interfaces instead.

  1x: The "Mockery\Adapter\Phpunit\Legacy\TestListenerForV7" class uses "PHPUnit\Framework\TestListenerDefaultImplementation" that is deprecated The `TestListener` interface is deprecated.

I'm guessing we need a Mockery\Adapter\Phpunit\Legacy\TestListenerForV8 class to migrate this in a similar way as the existing V7, V6 and V5

@rbaarsma
Copy link
Author

rbaarsma commented Nov 26, 2019

Solution is something like this

class TestExtension implements BeforeTestHook, AfterTestHook
{
    public function __construct()
    {
        $this->trait = new TestListenerTrait();
    }

    public function executeBeforeTest(string $test): void
    {
        $this->trait->startTestSuite();
    }

    public function executeAfterTest(string $test, float $time): void
    {
        $this->trait->endTest($test, $time);
    }
}

Used as an extension in phpunit.xml.dist:

    <extensions>
        <extension class="Mockery\Adapter\Phpunit\TestExtension" />
    </extensions>

For this last, we need to update the docs.

Note: extensions are usable from phpunit >= 7.1

@GrahamCampbell
Copy link
Contributor

This has been fixed in the 1.4 series @davedevelopment?

@davedevelopment
Copy link
Collaborator

I thought so, I think we nailed everything...

@GrahamCampbell
Copy link
Contributor

Note: extensions are usable from phpunit >= 7.1

@rbaarsma I think the situation is Mockery doesn't support PHPUnit 8 together with PHP 7.1 or 7.2. If you are using PHP 7.2 or lower with Mockery, PHPUnit 7 is the newest version of PHPUnit you can use. If you want to use PHPUnit 8 or newer, you must have PHP 7.3 or higher. I think this restriction is fine. You'll just need to make sure your builds pull the correction version combinations.

@trickeyone
Copy link

@davedevelopment I'm getting the deprecation warning with PHPUnit 9, Mockery 1.4.2.

1x: The "Mockery\Adapter\Phpunit\TestListener" class implements "PHPUnit\Framework\TestListener" that is deprecated Use the `TestHook` interfaces instead.

@GrahamCampbell
Copy link
Contributor

Which exact version of PHPUnit 9?

@trickeyone
Copy link

@GrahamCampbell 9.3.7 and 9.2.6 I have 2 different projects that are on the 2 different versions, and I'm seeing the message on both.

@trickeyone
Copy link

@GrahamCampbell I've updated my projects to 9.3.8 and the warning messages are still appearing. I see that the composer.json says it conflicts with PHPUnit <8.0, wouldn't it be prudent to use the new PHPUnit interfaces as indicated?

I am also seeing this message:

1x: The "Mockery\Adapter\Phpunit\TestListener" class uses "PHPUnit\Framework\TestListenerDefaultImplementation" that is deprecated

@trickeyone
Copy link

After looking into this a bit more, and looking at PHPUnit's own repo, I found sebastianbergmann/phpunit#3390. So, I think this is more on PHPUnit to fix the TestHook implementation before anything can really be done. With the current iteration of the TestHook architecture, I wasn't able to find an easy way to add Mockery's pre- or post-test hook functionality, as the Test object nor the TestResult are passed to the hook. Which was also brought up by greg0ire (sebastianbergmann/phpunit#3390 (comment)) in reference to Symfony's PHPUnit Bridge.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants