FriendsOfBehat / SymfonyExtension

:musical_score: Extension integrating Behat with Symfony.
MIT License
472 stars 62 forks source link

Symfony session parameters are not passed to AbstractBrowser #124

Open n1coh opened 4 years ago

n1coh commented 4 years ago

I try to migrate to Symfony 5 with latest FOB dependencies. I defined the a default behat config :

behat.yml

    Behat\MinkExtension:
        base_url: http://localhost
        files_path: 'tests/Behat/Features'
        default_session: symfony
        sessions:
            symfony:
                symfony: ~
    FriendsOfBehat\SymfonyExtension: null

But I got this error : Argument 2 passed to Symfony\Component\BrowserKit\AbstractBrowser::setServerParameter() must be of the type string, null given, called in /app/vendor/friends-of-behat/mink-browserkit-driver/src/BrowserKitDriver.php on line 58

I don't know if I'm doing bad or if this is a bug ... Can you help me please.

CocoJr commented 4 years ago

Same errors !

To fix it, I had to change my Behat\MinkExtension and remove the "base_url".

So now I have this configuration in my behat.yml.dist:

default:
    suites:
        default:
            paths:
                features: tests/features/
            contexts:
                - App\Tests\Behat\FixtureContext
                - behatch:context:browser
                - behatch:context:debug
                - behatch:context:system
                - behatch:context:json
                - behatch:context:table
                - behatch:context:rest
                - behatch:context:xml
    extensions:
        FriendsOfBehat\SymfonyExtension: ~
        Behat\MinkExtension:
            sessions:
                symfony:
                    symfony: ~
        Behatch\Extension: ~

and my composer looks like:

    "require-dev": {
        "behatch/contexts": "^3.3",
        "friends-of-behat/mink": "^1.8",
        "friends-of-behat/mink-browserkit-driver": "^1.4",
        "friends-of-behat/mink-extension": "^2.4",
        "friends-of-behat/symfony-extension": "^2.0",
        "hautelook/alice-bundle": "^2.7",
        "symfony/maker-bundle": "^1.15"
    },

EDIT: I think the documentation need to be completed and insist in the fact that the base_url for mink has to be omitted !

n1coh commented 4 years ago

I found that the typed parameter of method setServerParameter was the problem and just adding a "/" is a solution : base_url: http://localhost/

pamil commented 4 years ago

@n1coh nice catch! Indeed, it works for us at Sylius with / at the end.