doutandusegang2961 2015-07-26 23:54 采纳率: 0%
浏览 58
已采纳

运行behat输出烦人的PHP严格标准错误/通知

I have tried implementing answers from these two questions:

But no luck: whenever I run behat, I still get this message before the features are run:

PHP Strict standards:  Declaration of Behat\Behat\Console\Input\InputDefinition::getSynopsis() should be compatible with Symfony\Component\Console\Input\InputDefinition::getSynopsis($short = false) in C:\phpbin\behat\vendor\behat\behat\src\Behat\Behat\Console\Input\InputDefinition.php on line 157
PHP Stack trace:
PHP   1. {main}() C:\phpbin\behat\vendor\behat\behat\bin\behat:0
PHP   2. Symfony\Component\Console\Application->run() C:\phpbin\behat\vendor\behat\behat\bin\behat:32
PHP   3. Behat\Behat\Console\BehatApplication->doRun() C:\phpbin\behat\vendor\symfony\console\Application.php:126
PHP   4. Behat\Behat\Console\BehatApplication->createCommand() C:\phpbin\behat\vendor\behat\behat\src\Behat\Behat\Console\BehatApplication.php:66
PHP   5. Symfony\Component\DependencyInjection\ContainerBuilder->get() C:\phpbin\behat\vendor\behat\behat\src\Behat\Behat\Console\BehatApplication.php:80
PHP   6. Symfony\Component\DependencyInjection\ContainerBuilder->createService() C:\phpbin\behat\vendor\symfony\dependency-injection\ContainerBuilder.php:504
PHP   7. ReflectionClass->newInstanceArgs() C:\phpbin\behat\vendor\symfony\dependency-injection\ContainerBuilder.php:980
PHP   8. Behat\Behat\Console\Command\BehatCommand->__construct() C:\phpbin\behat\vendor\symfony\dependency-injection\ContainerBuilder.php:980
PHP   9. Composer\Autoload\ClassLoader->loadClass() C:\phpbin\behat\vendor\symfony\dependency-injection\ContainerBuilder.php:0
PHP  10. Composer\Autoload\includeFile() C:\phpbin\behat\vendor\composer\ClassLoader.php:301

Strict standards: Declaration of Behat\Behat\Console\Input\InputDefinition::getSynopsis() should be compatible with Symfony\Component\Console\Input\InputDefinition::getSynopsis($short = false) in C:\phpbin\behat\vendor\behat\behat\src\Behat\Behat\Console\Input\InputDefinition.php on line 157

Call Stack:
    0.0003     237800   1. {main}() C:\phpbin\behat\vendor\behat\behat\bin\behat:0
    0.0250    1812816   2. Symfony\Component\Console\Application->run() C:\phpbin\behat\vendor\behat\behat\bin\behat:32
    0.0331    2201280   3. Behat\Behat\Console\BehatApplication->doRun() C:\phpbin\behat\vendor\symfony\console\Application.php:126
    0.0331    2201344   4. Behat\Behat\Console\BehatApplication->createCommand() C:\phpbin\behat\vendor\behat\behat\src\Behat\Behat\Console\BehatApplication.php:66
    0.2716    6867024   5. Symfony\Component\DependencyInjection\ContainerBuilder->get() C:\phpbin\behat\vendor\behat\behat\src\Behat\Behat\Console\BehatApplication.php:80
    0.2717    6868160   6. Symfony\Component\DependencyInjection\ContainerBuilder->createService() C:\phpbin\behat\vendor\symfony\dependency-injection\ContainerBuilder.php:504
    0.2903    7223504   7. ReflectionClass->newInstanceArgs() C:\phpbin\behat\vendor\symfony\dependency-injection\ContainerBuilder.php:980
    0.2903    7225288   8. Behat\Behat\Console\Command\BehatCommand->__construct() C:\phpbin\behat\vendor\symfony\dependency-injection\ContainerBuilder.php:980
    0.2904    7226416   9. Composer\Autoload\ClassLoader->loadClass() C:\phpbin\behat\vendor\symfony\dependency-injection\ContainerBuilder.php:0
    0.2909    7226568  10. Composer\Autoload\includeFile() C:\phpbin\behat\vendor\composer\ClassLoader.php:301

Feature: Search
  In order to use the admin pages
  As me (admin)
  I need to be able to load the pages

  Scenario: Navigating to the admin home page - check title and main heading # features\wikipedia.feature:6
    Given I am on "/dabblelabs/admin"                                        # FeatureContext::visit()
    Then I should see "Admin" in the "body" element                          # FeatureContext::assertElementContainsText()
    Then the element "body" should contain "Admin Home"                      # FeatureContext::assertElementContainsString()
    Then the title contains "Admin Home"                                     # FeatureContext::assertTitleContains()

1 scenario (1 passed)
4 steps (4 passed)
0m0.245s

In my FeatureContext.php file, above the class definition, I have:

ini_set('display_errors', '0');
error_reporting(E_ALL & ~E_STRICT);
define('BEHAT_ERROR_REPORTING', E_ERROR);

But I still get the errors. How can I hide them?

  • 写回答

2条回答 默认 最新

  • dpj96988 2015-08-01 09:23
    关注

    It turns out that I had followed several out of date tutorials which used an old, unmaintained version of Behat (2.4.*). I learnt that by raising an issue on Behat's Github repo:

    https://github.com/Behat/Behat/issues/773#issuecomment-126410052

    The composer.json that finally worked for me was:

    {
        "require": {
            "behat/behat": "@stable",
            "behat/symfony2-extension": "@stable",
            "behat/mink": "@stable",
            "behat/mink-extension": "@stable",
            "behat/mink-browserkit-driver": "@stable",
            "behat/mink-goutte-driver": "@stable",
            "behat/mink-selenium2-driver": "@stable",
            "phpunit/php-code-coverage": "@stable",
            "phpunit/phpunit-mock-objects": "@stable",
            "phpunit/phpunit": "@stable"
            },
        "config": {
            "bin-dir": "bin/"
        }
    }
    

    And my behat.yml was:

    default:
      suites:
          default:
              contexts:
                  - FeatureContext:
                      parameters:
                          my_empty_array:
                              'mydummykey1': 'mydummyvalue1'
      extensions:
        Behat\MinkExtension:
          base_url: http://localhost
          goutte: ~
          selenium2: ~
    
    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论
查看更多回答(1条)

报告相同问题?

悬赏问题

  • ¥20 有关区间dp的问题求解
  • ¥15 多电路系统共用电源的串扰问题
  • ¥15 slam rangenet++配置
  • ¥15 有没有研究水声通信方面的帮我改俩matlab代码
  • ¥15 对于相关问题的求解与代码
  • ¥15 ubuntu子系统密码忘记
  • ¥15 信号傅里叶变换在matlab上遇到的小问题请求帮助
  • ¥15 保护模式-系统加载-段寄存器
  • ¥15 电脑桌面设定一个区域禁止鼠标操作
  • ¥15 求NPF226060磁芯的详细资料