giorgiosironi / phpunit-selenium

Selenium RC integration for PHPUnit
http://www.phpunit.de/
Other
602 stars 271 forks source link

PHP Warning: Declaration of PHPUnit_Extensions_Selenium2TestCase::on… #366

Closed WybrenKoelmans closed 8 years ago

WybrenKoelmans commented 8 years ago

…NotSuccessfulTest(Exception $e) be compatible with PHPUnit_Framework_TestCase::onNotSuccessfulTest($e)

The overriding method does not match the signature of the parent anymore since PHPUnit 5.0.0.

https://github.com/sebastianbergmann/phpunit/commit/43aa49206b155931db36463c6b908a29d32361aa

giorgiosironi commented 8 years ago

I need to test this and cross-check compatibility requirements written in the composer.json, then I'll merge.

giorgiosironi commented 8 years ago

We are still supporting PHPUnit 4.8, would this mean we have to drop support for it or it it compatible with both the 4.x and 5.x lines?

WybrenKoelmans commented 8 years ago

This can not be compatible with both, since it is impossible to implement both

PHPUnit 4.8:

public function onNotSuccessfulTest(Exception $e)

and PHPUnit 5.0:

public function onNotSuccessfulTest($e)

in PHPUnit_Extensions_Selenium2TestCase at the same time.

Maybe it would be best to merge this into a branch that is >= 5.0.0 only.

Ignoring the issue however will mark tests as failed if PHPUnit is strict about warnings generated. To solve that problem it is possible to use this workaround http://stackoverflow.com/questions/8412746/ignoring-the-php-warnings-in-phpunit, however this might suppress other warnings you do want to know about.

giorgiosironi commented 8 years ago

This hook is used to reset the shared browser session between tests. I have tried implementing the same functionality with PHPUnit listeners, but it seems not possible as I would close the session before the listeners are run (so for example the screenshot listener would not work). Going back to the drawing board...

WybrenKoelmans commented 8 years ago

I actually ran in to this while implementing a listener for screenshots on onNotSuccessfulTest. Thank you for your effort, let me know if you need any more information.

giorgiosironi commented 8 years ago

Let's go for:

Feedback on these decisions?

giorgiosironi commented 8 years ago

Also, for screenshots use or fork this https://github.com/giorgiosironi/phpunit-selenium/blob/master/PHPUnit/Extensions/Selenium2TestCase/ScreenshotListener.php

WybrenKoelmans commented 8 years ago

I agree, however don't forget to update the composer.json to show that phpunit-selenium 2.x.x only supports PHPUnit 4.x.x

...
"require": {
        "phpunit/phpunit": ">=4.8,<5.0"
    },
...

and master:

...
"require": {
        "phpunit/phpunit": ">=5.0,<6.0"
    },
...

(or such)

ctrlaltca commented 8 years ago

I just stumbled upon this problem, and the proposed fix solves the problem for me. :+1: