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 虚幻5 UE美术毛发渲染
  • ¥15 CVRP 图论 物流运输优化
  • ¥15 Tableau online 嵌入ppt失败
  • ¥100 支付宝网页转账系统不识别账号
  • ¥15 基于单片机的靶位控制系统
  • ¥15 真我手机蓝牙传输进度消息被关闭了,怎么打开?(关键词-消息通知)
  • ¥15 装 pytorch 的时候出了好多问题,遇到这种情况怎么处理?
  • ¥20 IOS游览器某宝手机网页版自动立即购买JavaScript脚本
  • ¥15 手机接入宽带网线,如何释放宽带全部速度
  • ¥30 关于#r语言#的问题:如何对R语言中mfgarch包中构建的garch-midas模型进行样本内长期波动率预测和样本外长期波动率预测