Question

I am using composer with Symfony 2.0.15 and migrating to latest Behat 2.4. This is in my composer.json:

"require-dev": {
    "behat/behat": "2.4@stable",
    "behat/mink-extension": "*",
    "behat/symfony2-extension": "*",
    "behat/mink-browserkit-driver":  "*",
    "behat/mink-goutte-driver":  "dev-master",
    "behat/common-contexts": "*",
    "kriswallsmith/buzz": ">=0.5.0"
}

I run: php composer.phar update --dev

And there is an error:

Your requirements could not be solved to an installable set of packages.

Problem 1
- Installation request for behat/mink-goutte-driver dev-master -> satisfiable by behat/mink-goutte-driver dev-master.
- don't install fabpot/goutte 1.0.x-dev|install fabpot/goutte dev-master
- behat/mink-goutte-driver dev-master requires fabpot/goutte 1.0.* -> satisfiable by fabpot/goutte 1.0.x-dev.
- Conclusion: remove symfony/symfony v2.0.15
- fabpot/goutte dev-master requires symfony/dom-crawler 2.1.* -> satisfiable by symfony/symfony 2.1.x-dev, symfony/dom-crawler v2.1.0-BETA1, symfony/dom-crawler 2.1.x-dev, symfony/symfony v2.1.0-BETA1.
- Can only install one of: symfony/symfony v2.0.15, symfony/symfony 2.1.x-dev.
- Can only install one of: symfony/symfony v2.1.0-BETA1, symfony/symfony v2.0.15.
- don't install symfony/symfony v2.0.15|don't install symfony/dom-crawler v2.1.0-BETA1
- don't install symfony/dom-crawler 2.1.x-dev|don't install symfony/symfony v2.0.15
- Installation request for symfony/symfony == 2.0.15.0 -> satisfiable by symfony/symfony v2.0.15.

If I understand the error correctly, it is because fabpot/goutte package is dependent on Symfony 2.1 packages and not available for Symfony 2.0. Correct me, if I am wrong.

Here is my behat.yml:

default:
    formatter:
      parameters:
        paths: false
     context:
      class: 'Site\PublicBundle\Features\Context\FeatureContext'
      parameters:
        base_url:  'http://test-anton.site.com'
    extensions:
      Behat\Symfony2Extension\Extension:
        mink_driver: true
        bundle: 'PublicBundle'
        kernel:
          env: test
          debug: true
      Behat\MinkExtension\Extension:
        default_session: symfony2
        base_url:  'http://test-anton.site.com'

And this is sample of my failing scenario:

Scenario: User can view homepage
    When I go to "/"
    Then the response code should be 200

"When I go to" - is a MinkContext step, but "Then the response code should be 200" - is a step from Behat\CommonContexts\WebApiContext. When I use only steps from MinkContext - "Then the response status code should be 200" it works just fine.


The final answer is that Behat\CommonContexts\WebApiContext is not compatible with Behat 2.4.

Was it helpful?

Solution

Might be a stupid question but do you use goutte? I went through a similar update recently and mink-browserkit-driver was all I needed.

I'm not sure why goutte has a dependency on 2.1 and it might be risky to use it with 2.0. If you really need it try defining a custom repository for goutte in your composer.json (and lie about requirements on Symfony).

Update

Notice that error message says "Call to a member function getUri()". It relates to getCurrentUri():

public function getCurrentUrl()
{
     return $this->client->getRequest()->getUri();
}

It means that client is there but getRequest() returns null. That suggests request was not made yet.

Did you make a request before accessing its URL?

Installing Goutte won't solve your issue (you don't need it at all).

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top