2012-10-24 295 views
1

是否有一些關於如何使用Zend Framework 2配置Behat的教程或示例?我已經嘗試了兩天,但我無法弄清楚。Zend Framework 2 Behat

任何幫助,將不勝感激。我試圖做BDD與Zend框架2.

編輯:

基本上,我試圖通過作曲家貝哈特安裝時遇到了問題。這是我的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" 
    } 
} 

當我運行:

php composer.phar update --dev 

我得到:

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. 

作曲家JSON文件工作正常,當我刪除貝哈特線。

EDIT2:

我的臨時解決方案哈克:

"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/" 
    ] 
} 

回答

0

這工作,最後:

{ 
    "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/" 
     } 
    } 
} 
2

瑞安韋弗剛剛發佈的幻燈片從有關的ZendCon:Behavioral Driven Development with Behat and Zend Framework 2

您可以跳轉到the slide 56來看看如何在ZF2安裝貝哈特:

  1. 下載作曲

    $> curl -s http://getcomposer.org/installer | php 
    
  2. 爲貝哈特(see the doc

    創建(或更新)composer.json
    { 
        "require": { 
         "behat/behat": "2.4.*@stable" 
        }, 
        "minimum-stability": "dev", 
        "config": { 
         "bin-dir": "bin/" 
        } 
    } 
    
  3. 下載Behat庫

    $> php composer.phar install 
    
  4. 然後啓動貝哈特從控制檯

    php bin/behat --help 
    

編輯:

你不應該把貝哈特爲require-dev,嘗試用這個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.*" 
    } 
} 
+0

是的,我已經試過了,當然,但也有很多與作曲家依賴性問題。基本上我不能讓Behat通過作曲家和Zend Framework 2一起工作,它在我剛剛克隆版本庫時起作用。 –

+0

你有使用作曲家的哪種類型的問題? – j0k

+0

我用我的composer.json文件和我得到的錯誤消息更新了我的問題。 –