我试着从这两个问题中实现答案:
- 是否有一种方法可以让PHP通知错误不失败?
- 当出现E_USER_DEPRECATED级别的错误时,如何运行Behat测试
但是运气不好:每当我运行behat时,我仍然会在功能运行之前得到这个消息:
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
在我的FeatureContext.php文件中,在类定义上面,我有:
ini_set('display_errors', '0');
error_reporting(E_ALL & ~E_STRICT);
define('BEHAT_ERROR_REPORTING', E_ERROR);
但是我仍然得到错误。我怎样才能把它们藏起来?
我不是PRO in a Symphony and Behat但是
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
这个错误告诉你有不匹配的函数声明
我看到解决问题的一种方法,在Behat'Behat'Console'Input'InputDefinition::getSynopsis($short = false)的声明中添加$short = false
这不会改变什么,但是行为中的反射会停止打扰你
原来我遵循了几个过时的教程,这些教程使用的是旧的、未维护的Behat版本(2.4.*)。我通过在Behat的Github repo上提出一个问题了解到这一点:
https://github.com/Behat/Behat/issues/773 issuecomment - 126410052
作曲家。最终为我工作的Json是:
{
"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/"
}
}
和我的行为。yml:
default:
suites:
default:
contexts:
- FeatureContext:
parameters:
my_empty_array:
'mydummykey1': 'mydummyvalue1'
extensions:
Behat'MinkExtension:
base_url: http://localhost
goutte: ~
selenium2: ~