Behatch / contexts

Behat extension with most custom helper steps
Other
394 stars 203 forks source link

Symfony 5 compatibility #281

Closed alanpoulain closed 4 years ago

alanpoulain commented 4 years ago

Fixes #279.

The MinkExtension from Behat (https://github.com/Behat/MinkExtension) has been replaced by the one from FriendsOfBehat (https://github.com/FriendsOfBehat/MinkExtension) because it is more actively maintained (and supports Symfony 5).

guelosuperstart commented 4 years ago

Hello @alanpoulain, Thank you for your PR, when will it be merged ? Is It possible to use your branch: sf5-compatibility?

alanpoulain commented 4 years ago

It doesn't depend on me, sorry. Yes you should be able to use my branch with the right Composer configuration.

guelosuperstart commented 4 years ago

@alanpoulain : what is the right way to use with composer ?

thks

alanpoulain commented 4 years ago

And Travis should be green now!

sanpii commented 4 years ago

Thank you very much :tada:

guelosuperstart commented 4 years ago

@alanpoulain Thank you very much for your PR.

i have just tested it on my SF5 project, but i have some problems :/

  Problem 1
    - behat/mink v1.7.1 requires symfony/css-selector ~2.1|~3.0 -> no matching package found.
    - behat/mink v1.7.0 requires symfony/css-selector ~2.1 -> no matching package found.
    - behat/mink v1.6.1 requires symfony/css-selector ~2.0 -> no matching package found.
    - behat/mink v1.6.0 requires symfony/css-selector ~2.0 -> no matching package found.
    - behat/mink v1.5.0 requires symfony/css-selector ~2.0 -> no matching package found.
    - friends-of-behat/mink-extension 2.3.1 requires symfony/config ^2.7|^3.0|^4.0 -> no matching package found.
    - behatch/contexts 3.3.0 requires friends-of-behat/mink-extension ^2.3.1 -> satisfiable by friends-of-behat/mink-extension[2.3.1, v2.4.0].
    - friends-of-behat/mink-extension v2.4.0 requires behat/mink ^1.5 -> satisfiable by behat/mink[v1.5.0, v1.6.0, v1.6.1, v1.7.0, v1.7.1].
    - Installation request for behatch/contexts ^3.3 -> satisfiable by behatch/contexts[3.3.0].

I use symfony/config v5.0.4in my project, but friends-of-behat/mink-extension:2.3.1 is not working with this package.

friends-of-behat/mink-extension:2.3.1 -> require symfony/config: ^2.7|^3.0|^4.0

is it possible to use the version 2.4.0 for friends-of-behat/mink-extension ? friends-of-behat/mink-extension:2.4.0 -> require symfony/config: ^4.4|^5.0

alanpoulain commented 4 years ago

@guelosuperstart you need to replace behat/mink (https://github.com/minkphp/Mink) with friends-of-behat/mink (https://github.com/FriendsOfBehat/Mink).

It tells Composer to replace the old package by itself (https://github.com/FriendsOfBehat/Mink/blob/28798f57e9674cb99750606807d623bbc0ae6db3/composer.json#L27).

Try to do this:

composer require --dev friends-of-behat/mink behatch/contexts
guelosuperstart commented 4 years ago

Thank you @alanpoulain, I have just tested your solution and it works like a charm: D

So to use behat with behatch/contexts& mink in SF5 we should install like this :

composer require --dev friends-of-behat/mink friends-of-behat/mink-browserkit-driver behatch/contexts friends-of-behat/symfony-extension:v2.1.0-BETA.1
adrienfr commented 4 years ago

Hi,

Thank you for the SF5 compatibility!

Since Composer 1.10 release (here): I have the following deprecation notice message:

Warning: Ambiguous class resolution, "Behat\MinkExtension\Listener\SessionsListener" was found 2x: in "/var/www/morningcroissant/symfony/vendor/behat/mink-extension/src/Behat/MinkExtension/Listener/SessionsListener.php" and "/var/www/morningcroissant/symfony/vendor/friends-of-behat/mink-extension/src/Behat/MinkExtension/Listener/SessionsListener.php", the first will be used.

In composer.lock, I have :

Do you know how we can fix this?

Thanks

alanpoulain commented 4 years ago

Symfony2Extension is not really maintained anymore. I suggest you to use https://github.com/FriendsOfBehat/SymfonyExtension instead.

guelosuperstart commented 4 years ago

Hello @adrienfr ,

In my SF5 project, i have installed behat, behatch/contexts& mink like this:

composer require --dev friends-of-behat/mink friends-of-behat/mink-browserkit-driver behatch/contexts friends-of-behat/symfony-extension:v2.1.0-BETA.1

i use friends-of-behat/symfony-extension:v2.1.0-BETA.1 instead of Symfony2Extension

adrienfr commented 4 years ago

Thanks @alanpoulain & @guelosuperstart but I use behat/mink-selenium2-driver and there is no such thing in friends-of-behat/.

I tried to mix behat/mink-selenium2-driver with friends-of-behat/mink friends-of-behat/mink-browserkit-driver behatch/contexts friends-of-behat/symfony-extension but Selenium won't work:

AfterStep # Behatch\Context\DebugContext::failScreenshots() Fatal error: Call to a member function screenshot() on null (Behat\Testwork\Call\Exception\FatalThrowableError)

AfterScenario # Behatch\Context\BrowserContext::closeBrowser() Could not connect to a Selenium 2 / WebDriver server (Behat\Mink\Exception\DriverException)