dougehe2022 2014-10-14 07:42
浏览 78
已采纳

Behat无法初始化:Client :: createResponse()的声明应该与createResponse()兼容

I am trying to set-up Behat but it fails to init when I run bin/behat --init. My composer.json is taken from the official docs:

{
    "require": {
        "behat/behat": "2.4.*@stable",
        "behat/mink": "1.4.*@stable",
        "behat/mink-extension": "*",
        "behat/mink-goutte-driver": "*",
        "behat/mink-selenium2-driver": "*"
    },
    "minimum-stability": "dev",
    "config": {
        "bin-dir": "bin/"
    }
}

The composer install works fine and looks like all dependencies get installed.

# behat.yml
default:
  paths:
    features:  features
    bootstrap: features/bootstrap

  extensions:
    Behat\MinkExtension\Extension:
      base_url: http://en.wikipedia.org
      goutte: ~
      selenium2: ~

annotations:
  paths:
    features: features/annotations

closures:
  paths:
    features: features/closures 

Running # bin/behat --init yields the following error:

PHP Strict Standards:  Declaration of Behat\Mink\Driver\Goutte\Client::createResponse() should be compatible with Goutte\Client::createResponse(GuzzleHttp\Message\Response $response) in /web/Test-1/vendor/behat/mink-goutte-driver/src/Behat/Mink/Driver/Goutte/Client.php on line 23

Strict Standards: Declaration of Behat\Mink\Driver\Goutte\Client::createResponse() should be compatible with Goutte\Client::createResponse(GuzzleHttp\Message\Response $response) in /web/Test-1/vendor/behat/mink-goutte-driver/src/Behat/Mink/Driver/Goutte/Client.php on line 23


  [ReflectionException]
  Class Guzzle\Http\Client does not exist

Could somebody tell me why? I did everything exactly like in official article.

  • 写回答

1条回答 默认 最新

  • doutangtan6386 2014-10-14 11:01
    关注

    You are using incompatible versions of Mink extensions / drivers. The following pulls the latest versions compatible (right now) with Behat 3 and Mink 1.6, while you want to use much older versions (2.4.* and 1.4.* respectively).

    "behat/mink-extension": "*",
    "behat/mink-goutte-driver": "*",
    "behat/mink-selenium2-driver": "*"
    

    I am assuming you've pulled this from the Internet, as I can't find a different example out there with fixed versions, which is pretty ironic, as the same people are probably blogging at the same time about how much of a bad practice that is. If you are just beginning, I suggest you stick with the latest versions of Behat and Mink, they are much better and have been more than stable for the past 6 months. Change you composer.json and update the dependencies:

    "behat/behat": "*",
    "behat/mink": "*"
    

    If not, go to each extension / driver repo and find the tagged version from early-mid 2013, that should fix it for the older packages.

    Update

    The code you provided doesn't work because you are using the old config format with the new Behat / Mink version. Don't forget, Behat 2 configs must be upgraded for Behat 3. Documentation is still pretty poor, but the basics are covered rather well here and here. Updating your config to this resolves the issue:

    default:
      extensions:
        Behat\MinkExtension:
          base_url: http://en.wikipedia.org
          goutte: ~
          selenium2: ~
    
      suites:
        default:
          paths: 
            - '%paths.base%/features'
    
        annotations:
          paths:
            - '%paths.base%/features/annotations'
    
        closures:
          paths:
            - '%paths.base%/features/closures'
    

    Here are the the packed files, just in case you get lost, the init command produces this:

    Ian-Bytcheks-MacBook-Pro:behat ianbytchek$ php ./vendor/bin/behat --init
    +d features - place your *.feature files here
    +d features/bootstrap - place your context classes here
    +f features/bootstrap/FeatureContext.php - place your definitions, transformations and hooks here
    +d features/annotations - place your *.feature files here
    +d features/closures - place your *.feature files here
    

    Update

    The root of all evil was the curl module, that was not installed in the author's environment. Instead of a proper warning php tried to mitigate the problem by using an alternative, which didn't help much.

    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论

报告相同问题?

悬赏问题

  • ¥15 如何在scanpy上做差异基因和通路富集?
  • ¥20 关于#硬件工程#的问题,请各位专家解答!
  • ¥15 关于#matlab#的问题:期望的系统闭环传递函数为G(s)=wn^2/s^2+2¢wn+wn^2阻尼系数¢=0.707,使系统具有较小的超调量
  • ¥15 FLUENT如何实现在堆积颗粒的上表面加载高斯热源
  • ¥30 截图中的mathematics程序转换成matlab
  • ¥15 动力学代码报错,维度不匹配
  • ¥15 Power query添加列问题
  • ¥50 Kubernetes&Fission&Eleasticsearch
  • ¥15 報錯:Person is not mapped,如何解決?
  • ¥15 c++头文件不能识别CDialog