dongyan3018
dongyan3018
2012-10-24 14:20

Zend Framework 2 Behat

已采纳

Is there some tutorial or example on how to configure Behat with Zend Framework 2? I have tried for two days but I cannot figure it out.

Any help would be appreciated. I am trying to do BDD with Zend Framework 2.

EDIT:

Basically, I am running into issues when trying to install Behat through composer. This is my composer.json:

{
    "name": "bla",
    "description": "Bla",
    "minimum-stability": "dev",
    "require": {
        "php": ">=5.4",
        "zendframework/zendframework": "2.*",
        "doctrine/doctrine-module": "dev-master",
        "doctrine/doctrine-orm-module": "0.*",
        "gedmo/doctrine-extensions": "dev-master"
    },
    "require-dev": {
        "phpunit/phpunit": "3.7.*",
        "behat/behat": "2.4.*@stable"
    }
}

When I run:

php composer.phar update --dev

I get:

php composer.phar update --dev
Loading composer repositories with package information
Updating dependencies
  - Updating gedmo/doctrine-extensions dev-master (fbf4a3 => 3033d7)
    Checking out 3033d7ecc6633b20bec3e9bcc2336219f3818068

Loading composer repositories with package information
Updating dev dependencies
Your requirements could not be resolved to an installable set of packages.

  Problem 1
    - Conclusion: don't install behat/behat v2.4.4
    - Conclusion: don't install behat/behat v2.4.3
    - Conclusion: don't install behat/behat v2.4.2
    - Conclusion: don't install behat/behat v2.4.1
    - Conclusion: remove doctrine/common dev-master
    - symfony/symfony 2.0.7 requires doctrine/common 2.1.* -> satisfiable by doctrine/common 2.1.3, doctrine/common 2.1.4, doctrine/common 2.1.x-dev.
    - symfony/symfony 2.0.x-dev requires doctrine/common >=2.1,<2.3-dev -> satisfiable by doctrine/common 2.1.3, doctrine/common 2.1.4, doctrine/common 2.1.x-dev, doctrine/common 2.2.0, doctrine/common 2.2.0-RC1, doctrine/common 2.2.0-RC3, doctrine/common 2.2.0-RC4, doctrine/common 2.2.0-RC5, doctrine/common 2.2.0BETA1, doctrine/common 2.2.0BETA2, doctrine/common 2.2.1, doctrine/common 2.2.2, doctrine/common 2.2.3, doctrine/common 2.2.x-dev.
    - symfony/symfony v2.0.10 requires doctrine/common 2.1.* -> satisfiable by doctrine/common 2.1.3, doctrine/common 2.1.4, doctrine/common 2.1.x-dev.
    - symfony/symfony v2.0.11 requires doctrine/common 2.1.* -> satisfiable by doctrine/common 2.1.3, doctrine/common 2.1.4, doctrine/common 2.1.x-dev.
    - symfony/symfony v2.0.12 requires doctrine/common 2.1.* -> satisfiable by doctrine/common 2.1.3, doctrine/common 2.1.4, doctrine/common 2.1.x-dev.
    - symfony/symfony v2.0.13 requires doctrine/common 2.1.* -> satisfiable by doctrine/common 2.1.3, doctrine/common 2.1.4, doctrine/common 2.1.x-dev.
    - symfony/symfony v2.0.14 requires doctrine/common 2.1.* -> satisfiable by doctrine/common 2.1.3, doctrine/common 2.1.4, doctrine/common 2.1.x-dev.
    - symfony/symfony v2.0.15 requires doctrine/common >=2.1,<2.3-dev -> satisfiable by doctrine/common 2.1.3, doctrine/common 2.1.4, doctrine/common 2.1.x-dev, doctrine/common 2.2.0, doctrine/common 2.2.0-RC1, doctrine/common 2.2.0-RC3, doctrine/common 2.2.0-RC4, doctrine/common 2.2.0-RC5, doctrine/common 2.2.0BETA1, doctrine/common 2.2.0BETA2, doctrine/common 2.2.1, doctrine/common 2.2.2, doctrine/common 2.2.3, doctrine/common 2.2.x-dev.
    - symfony/symfony v2.0.16 requires doctrine/common >=2.1,<2.3-dev -> satisfiable by doctrine/common 2.1.3, doctrine/common 2.1.4, doctrine/common 2.1.x-dev, doctrine/common 2.2.0, doctrine/common 2.2.0-RC1, doctrine/common 2.2.0-RC3, doctrine/common 2.2.0-RC4, doctrine/common 2.2.0-RC5, doctrine/common 2.2.0BETA1, doctrine/common 2.2.0BETA2, doctrine/common 2.2.1, doctrine/common 2.2.2, doctrine/common 2.2.3, doctrine/common 2.2.x-dev.
    - symfony/symfony v2.0.17 requires doctrine/common >=2.1,<2.3-dev -> satisfiable by doctrine/common 2.1.3, doctrine/common 2.1.4, doctrine/common 2.1.x-dev, doctrine/common 2.2.0, doctrine/common 2.2.0-RC1, doctrine/common 2.2.0-RC3, doctrine/common 2.2.0-RC4, doctrine/common 2.2.0-RC5, doctrine/common 2.2.0BETA1, doctrine/common 2.2.0BETA2, doctrine/common 2.2.1, doctrine/common 2.2.2, doctrine/common 2.2.3, doctrine/common 2.2.x-dev.
    - symfony/symfony v2.0.18 requires doctrine/common >=2.1,<2.3-dev -> satisfiable by doctrine/common 2.1.3, doctrine/common 2.1.4, doctrine/common 2.1.x-dev, doctrine/common 2.2.0, doctrine/common 2.2.0-RC1, doctrine/common 2.2.0-RC3, doctrine/common 2.2.0-RC4, doctrine/common 2.2.0-RC5, doctrine/common 2.2.0BETA1, doctrine/common 2.2.0BETA2, doctrine/common 2.2.1, doctrine/common 2.2.2, doctrine/common 2.2.3, doctrine/common 2.2.x-dev.
    - symfony/symfony v2.0.9 requires doctrine/common 2.1.* -> satisfiable by doctrine/common 2.1.3, doctrine/common 2.1.4, doctrine/common 2.1.x-dev.
    - symfony/symfony 2.1.x-dev requires doctrine/common >2.2,<2.4-dev -> satisfiable by doctrine/common 2.2.1, doctrine/common 2.2.2, doctrine/common 2.2.3, doctrine/common 2.2.x-dev, doctrine/common 2.3.0, doctrine/common 2.3.0-BETA1, doctrine/common 2.3.0-RC1, doctrine/common 2.3.0-RC2, doctrine/common 2.3.0-RC3, doctrine/common 2.3.x-dev.
    - symfony/symfony dev-master requires doctrine/common >2.2,<2.4-dev -> satisfiable by doctrine/common 2.2.1, doctrine/common 2.2.2, doctrine/common 2.2.3, doctrine/common 2.2.x-dev, doctrine/common 2.3.0, doctrine/common 2.3.0-BETA1, doctrine/common 2.3.0-RC1, doctrine/common 2.3.0-RC2, doctrine/common 2.3.0-RC3, doctrine/common 2.3.x-dev.
    - symfony/symfony 2.2.x-dev requires doctrine/common >2.2,<2.4-dev -> satisfiable by doctrine/common 2.2.1, doctrine/common 2.2.2, doctrine/common 2.2.3, doctrine/common 2.2.x-dev, doctrine/common 2.3.0, doctrine/common 2.3.0-BETA1, doctrine/common 2.3.0-RC1, doctrine/common 2.3.0-RC2, doctrine/common 2.3.0-RC3, doctrine/common 2.3.x-dev.
    - symfony/symfony v2.1.0 requires doctrine/common >2.2,<2.4-dev -> satisfiable by doctrine/common 2.2.1, doctrine/common 2.2.2, doctrine/common 2.2.3, doctrine/common 2.2.x-dev, doctrine/common 2.3.0, doctrine/common 2.3.0-BETA1, doctrine/common 2.3.0-RC1, doctrine/common 2.3.0-RC2, doctrine/common 2.3.0-RC3, doctrine/common 2.3.x-dev.
    - symfony/symfony v2.1.0-BETA1 requires doctrine/common >2.2,<2.4-dev -> satisfiable by doctrine/common 2.2.1, doctrine/common 2.2.2, doctrine/common 2.2.3, doctrine/common 2.2.x-dev, doctrine/common 2.3.0, doctrine/common 2.3.0-BETA1, doctrine/common 2.3.0-RC1, doctrine/common 2.3.0-RC2, doctrine/common 2.3.0-RC3, doctrine/common 2.3.x-dev.
    - symfony/symfony v2.1.0-BETA2 requires doctrine/common >2.2,<2.4-dev -> satisfiable by doctrine/common 2.2.1, doctrine/common 2.2.2, doctrine/common 2.2.3, doctrine/common 2.2.x-dev, doctrine/common 2.3.0, doctrine/common 2.3.0-BETA1, doctrine/common 2.3.0-RC1, doctrine/common 2.3.0-RC2, doctrine/common 2.3.0-RC3, doctrine/common 2.3.x-dev.
    - symfony/symfony v2.1.0-BETA3 requires doctrine/common >2.2,<2.4-dev -> satisfiable by doctrine/common 2.2.1, doctrine/common 2.2.2, doctrine/common 2.2.3, doctrine/common 2.2.x-dev, doctrine/common 2.3.0, doctrine/common 2.3.0-BETA1, doctrine/common 2.3.0-RC1, doctrine/common 2.3.0-RC2, doctrine/common 2.3.0-RC3, doctrine/common 2.3.x-dev.
    - symfony/symfony v2.1.0-BETA4 requires doctrine/common >2.2,<2.4-dev -> satisfiable by doctrine/common 2.2.1, doctrine/common 2.2.2, doctrine/common 2.2.3, doctrine/common 2.2.x-dev, doctrine/common 2.3.0, doctrine/common 2.3.0-BETA1, doctrine/common 2.3.0-RC1, doctrine/common 2.3.0-RC2, doctrine/common 2.3.0-RC3, doctrine/common 2.3.x-dev.
    - symfony/symfony v2.1.0-RC1 requires doctrine/common >2.2,<2.4-dev -> satisfiable by doctrine/common 2.2.1, doctrine/common 2.2.2, doctrine/common 2.2.3, doctrine/common 2.2.x-dev, doctrine/common 2.3.0, doctrine/common 2.3.0-BETA1, doctrine/common 2.3.0-RC1, doctrine/common 2.3.0-RC2, doctrine/common 2.3.0-RC3, doctrine/common 2.3.x-dev.
    - symfony/symfony v2.1.0-RC2 requires doctrine/common >2.2,<2.4-dev -> satisfiable by doctrine/common 2.2.1, doctrine/common 2.2.2, doctrine/common 2.2.3, doctrine/common 2.2.x-dev, doctrine/common 2.3.0, doctrine/common 2.3.0-BETA1, doctrine/common 2.3.0-RC1, doctrine/common 2.3.0-RC2, doctrine/common 2.3.0-RC3, doctrine/common 2.3.x-dev.
    - symfony/symfony v2.1.1 requires doctrine/common >2.2,<2.4-dev -> satisfiable by doctrine/common 2.2.1, doctrine/common 2.2.2, doctrine/common 2.2.3, doctrine/common 2.2.x-dev, doctrine/common 2.3.0, doctrine/common 2.3.0-BETA1, doctrine/common 2.3.0-RC1, doctrine/common 2.3.0-RC2, doctrine/common 2.3.0-RC3, doctrine/common 2.3.x-dev.
    - symfony/symfony v2.1.2 requires doctrine/common >2.2,<2.4-dev -> satisfiable by doctrine/common 2.2.1, doctrine/common 2.2.2, doctrine/common 2.2.3, doctrine/common 2.2.x-dev, doctrine/common 2.3.0, doctrine/common 2.3.0-BETA1, doctrine/common 2.3.0-RC1, doctrine/common 2.3.0-RC2, doctrine/common 2.3.0-RC3, doctrine/common 2.3.x-dev.
    - Can only install one of: doctrine/common dev-master, doctrine/common 2.1.3.
    - Can only install one of: doctrine/common dev-master, doctrine/common 2.1.4.
    - Can only install one of: doctrine/common dev-master, doctrine/common 2.1.x-dev.
    - Can only install one of: doctrine/common dev-master, doctrine/common 2.2.0.
    - Can only install one of: doctrine/common dev-master, doctrine/common 2.2.0-RC1.
    - Can only install one of: doctrine/common dev-master, doctrine/common 2.2.0-RC3.
    - Can only install one of: doctrine/common dev-master, doctrine/common 2.2.0-RC4.
    - Can only install one of: doctrine/common dev-master, doctrine/common 2.2.0-RC5.
    - Can only install one of: doctrine/common dev-master, doctrine/common 2.2.0BETA1.
    - Can only install one of: doctrine/common dev-master, doctrine/common 2.2.0BETA2.
    - Can only install one of: doctrine/common dev-master, doctrine/common 2.2.1.
    - Can only install one of: doctrine/common dev-master, doctrine/common 2.2.2.
    - Can only install one of: doctrine/common dev-master, doctrine/common 2.2.3.
    - Can only install one of: doctrine/common dev-master, doctrine/common 2.2.x-dev.
    - Can only install one of: doctrine/common dev-master, doctrine/common 2.3.0.
    - Can only install one of: doctrine/common dev-master, doctrine/common 2.3.0-BETA1.
    - Can only install one of: doctrine/common dev-master, doctrine/common 2.3.0-RC1.
    - Can only install one of: doctrine/common dev-master, doctrine/common 2.3.0-RC2.
    - Can only install one of: doctrine/common dev-master, doctrine/common 2.3.0-RC3.
    - Can only install one of: doctrine/common dev-master, doctrine/common 2.3.x-dev.
    - Installation request for doctrine/common dev-master -> satisfiable by doctrine/common dev-master.
    - Installation request for behat/behat 2.4.*@stable -> satisfiable by behat/behat v2.4.0, behat/behat v2.4.1, behat/behat v2.4.2, behat/behat v2.4.3, behat/behat v2.4.4.
    - Conclusion: remove symfony/console dev-master|install symfony/symfony 2.0.7|install symfony/symfony 2.0.x-dev|install symfony/symfony 2.1.x-dev|install symfony/symfony v2.0.10|install symfony/symfony v2.0.11|install symfony/symfony v2.0.12|install symfony/symfony v2.0.13|install symfony/symfony v2.0.14|install symfony/symfony v2.0.15|install symfony/symfony v2.0.16|install symfony/symfony v2.0.17|install symfony/symfony v2.0.18|install symfony/symfony v2.0.9|install symfony/symfony v2.1.0|install symfony/symfony v2.1.0-BETA1|install symfony/symfony v2.1.0-BETA2|install symfony/symfony v2.1.0-BETA3|install symfony/symfony v2.1.0-BETA4|install symfony/symfony v2.1.0-RC1|install symfony/symfony v2.1.0-RC2|install symfony/symfony v2.1.1|install symfony/symfony v2.1.2
    - behat/behat v2.4.0 requires symfony/console >=2.0.0,<2.2.0-dev -> satisfiable by symfony/console 2.0.4, symfony/console 2.0.5, symfony/console 2.0.6, symfony/console 2.0.7, symfony/console 2.0.x-dev, symfony/console 2.1.x-dev, symfony/console v2.0.10, symfony/console v2.0.12, symfony/console v2.0.13, symfony/console v2.0.14, symfony/console v2.0.15, symfony/console v2.0.16, symfony/console v2.0.17, symfony/console v2.0.18, symfony/console v2.0.9, symfony/console v2.1.0, symfony/console v2.1.0-BETA1, symfony/console v2.1.0-BETA2, symfony/console v2.1.0-BETA3, symfony/console v2.1.0-BETA4, symfony/console v2.1.0-RC1, symfony/console v2.1.0-RC2, symfony/console v2.1.1, symfony/console v2.1.2, symfony/symfony 2.0.7, symfony/symfony 2.0.x-dev, symfony/symfony 2.1.x-dev, symfony/symfony v2.0.10, symfony/symfony v2.0.11, symfony/symfony v2.0.12, symfony/symfony v2.0.13, symfony/symfony v2.0.14, symfony/symfony v2.0.15, symfony/symfony v2.0.16, symfony/symfony v2.0.17, symfony/symfony v2.0.18, symfony/symfony v2.0.9, symfony/symfony v2.1.0, symfony/symfony v2.1.0-BETA1, symfony/symfony v2.1.0-BETA2, symfony/symfony v2.1.0-BETA3, symfony/symfony v2.1.0-BETA4, symfony/symfony v2.1.0-RC1, symfony/symfony v2.1.0-RC2, symfony/symfony v2.1.1, symfony/symfony v2.1.2.
    - Can only install one of: symfony/console dev-master, symfony/console 2.0.4.
    - Can only install one of: symfony/console dev-master, symfony/console 2.0.5.
    - Can only install one of: symfony/console dev-master, symfony/console 2.0.6.
    - Can only install one of: symfony/console dev-master, symfony/console 2.0.7.
    - Can only install one of: symfony/console dev-master, symfony/console 2.0.x-dev.
    - Can only install one of: symfony/console dev-master, symfony/console 2.1.x-dev.
    - Can only install one of: symfony/console v2.0.10, symfony/console dev-master.
    - Can only install one of: symfony/console v2.0.12, symfony/console dev-master.
    - Can only install one of: symfony/console v2.0.13, symfony/console dev-master.
    - Can only install one of: symfony/console v2.0.14, symfony/console dev-master.
    - Can only install one of: symfony/console v2.0.15, symfony/console dev-master.
    - Can only install one of: symfony/console v2.0.16, symfony/console dev-master.
    - Can only install one of: symfony/console v2.0.17, symfony/console dev-master.
    - Can only install one of: symfony/console v2.0.18, symfony/console dev-master.
    - Can only install one of: symfony/console v2.0.9, symfony/console dev-master.
    - Can only install one of: symfony/console v2.1.0, symfony/console dev-master.
    - Can only install one of: symfony/console v2.1.0-BETA1, symfony/console dev-master.
    - Can only install one of: symfony/console v2.1.0-BETA2, symfony/console dev-master.
    - Can only install one of: symfony/console v2.1.0-BETA3, symfony/console dev-master.
    - Can only install one of: symfony/console v2.1.0-BETA4, symfony/console dev-master.
    - Can only install one of: symfony/console v2.1.0-RC1, symfony/console dev-master.
    - Can only install one of: symfony/console v2.1.0-RC2, symfony/console dev-master.
    - Can only install one of: symfony/console v2.1.1, symfony/console dev-master.
    - Can only install one of: symfony/console v2.1.2, symfony/console dev-master.
    - Installation request for symfony/console dev-master -> satisfiable by symfony/console dev-master, symfony/symfony dev-master, symfony/symfony 2.2.x-dev.

The composer json file works fine when I remove the behat line.

EDIT2:

My temporary hacky solution:

"scripts": {
    "post-update-cmd": [
        "rm -rf vendor/Behat",
        "git clone git://github.com/Behat/Behat.git",
        "cp composer.phar Behat/composer.phar",
        "cd Behat && git submodule update --init",
        "cd Behat && php composer.phar install",
        "cd Behat && php composer.phar require guzzle/guzzle:3.0.*",
        "mv Behat vendor/Behat",
        "ln -sf ../Behat/bin/behat vendor/bin/"
    ]
}
  • 点赞
  • 写回答
  • 关注问题
  • 收藏
  • 复制链接分享
  • 邀请回答

2条回答

  • doucai7294 doucai7294 9年前

    This works, finally:

    {
        "name": "bla",
        "description": "bla",
        "minimum-stability": "dev",
        "require": {
            "php": ">=5.4",
            "symfony/console": ">=2.0.0,<2.2.0-dev",
            "symfony/config": ">=2.0.0,<2.2.0-dev",
            "symfony/dependency-injection": ">=2.0.0,<2.2.0-dev",
            "symfony/event-dispatcher": ">=2.0.0,<2.2.0-dev",
            "symfony/translation": ">=2.0.0,<2.2.0-dev",
            "symfony/yaml": ">=2.0.0,<2.2.0-dev",
            "symfony/finder": ">=2.0.0,<2.2.0-dev",
            "zendframework/zendframework": "2.*",
            "doctrine/doctrine-module": "dev-master",
            "doctrine/doctrine-orm-module": "0.*",
            "gedmo/doctrine-extensions": "dev-master"
        },
        "require-dev": {
            "phpunit/phpunit": "3.7.*",
            "behat/behat": "2.4.*@stable",
            "guzzle/guzzle": "3.0.*"
        },
        "autoload": {
            "psr-0": {
                "Behat\\Behat": "src/"
            }
        }
    }
    
    点赞 评论 复制链接分享
  • dongmangwei3822 dongmangwei3822 9年前

    Ryan Weaver just posted slides from the ZendCon about : Behavioral Driven Development with Behat and Zend Framework 2.

    You can jump to the slide 56 to see how to install Behat on ZF2:

    1. Download Composer

      $> curl -s http://getcomposer.org/installer | php
      
    2. Create (or update) composer.json for Behat (see the doc)

      {
          "require": {
              "behat/behat": "2.4.*@stable"
          },
          "minimum-stability": "dev",
          "config": {
              "bin-dir": "bin/"
          }
      }
      
    3. Download Behat libraries

      $> php composer.phar install
      
    4. Then launch Behat from console

      php bin/behat --help
      

    Edit:

    You shouldn't put behat into require-dev, try with this composer.json:

    {
        "name": "bla",
        "description": "Bla",
        "minimum-stability": "dev",
        "require": {
            "php": ">=5.4",
            "zendframework/zendframework": "2.*",
            "doctrine/doctrine-module": "dev-master",
            "doctrine/doctrine-orm-module": "0.*",
            "gedmo/doctrine-extensions": "dev-master",
            "behat/behat": "2.4.*@stable"
        },
        "require-dev": {
            "phpunit/phpunit": "3.7.*"
        }
    }
    
    点赞 评论 复制链接分享

为你推荐