我尝试过这两个问题的答案:
但没有运气:每当我运行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);
但我仍然得到错误。我该如何隐藏它们?
答案 0 :(得分:2)
我不是Symphony和Behat的PRO,但是
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
此错误表示您的功能声明不匹配
我看到1种解决问题的方法,在Behat \ Behat \ Console \ Input \ InputDefinition :: getSynopsis($ short = false)的声明中添加$ short = false
这将改变一切,但Behat中的反射会让你烦恼
答案 1 :(得分:0)
事实证明,我已经使用了几个过时的教程,这些教程使用了旧的,未维护的Behat版本(2.4。*)。我通过在Behat的Github回购中提出问题来了解到:
https://github.com/Behat/Behat/issues/773#issuecomment-126410052
最终为我工作的composer.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/"
}
}
我的behat.yml是:
default:
suites:
default:
contexts:
- FeatureContext:
parameters:
my_empty_array:
'mydummykey1': 'mydummyvalue1'
extensions:
Behat\MinkExtension:
base_url: http://localhost
goutte: ~
selenium2: ~