为什么magento behat测试找不到我的数据库? [英] Why can magento behat test not find my database?
问题描述
当我调用bin/behat
执行测试时,出现此错误:
When I call bin/behat
to execute my tests, I get this error:
test.dev bin/behat
[Zend_Db_Adapter_Exception]
SQLSTATE[HY000] [2002] No such file or directory
[PDOException]
SQLSTATE[HY000] [2002] No such file or directory
这是我的composer.json
:
{
"require": {
"php": ">=5.4.0"
},
"require-dev": {
"magetest/magento-behat-extension": "dev-develop",
"magetest/magento-phpspec-extension": "~2.0",
"peridot-php/webdriver-manager": "dev-master",
"bossa/phpspec2-expect": "dev-master",
"behat/mink-extension": "*",
"behat/mink-goutte-driver": "*",
"behat/mink-selenium2-driver": "*",
"behat/mink-selenium-driver": "*"
},
"autoload": {
"psr-0": {
"": [
"html/app",
"html/app/code/community",
"html/app/code/core",
"html/lib"
],
"Mage" : "html/app/code/core"
}
},
"config": {
"bin-dir": "bin"
}
}
这是我的behat.yml
:
default:
paths:
features: features
bootstrap: features/bootstrap
extensions:
MageTest\MagentoExtension\Extension: ~
Behat\MinkExtension\Extension:
base_url: http://test.dev
goutte: ~
selenium2: ~
default_session: selenium2
这是几个教程的拼凑而成,而每个教程都引发了相同的错误.我的Magento安装在项目下的html中.唯一与所有教程不同的是,我没有html/app/code/local
文件夹.
Composer install和behat --init运行没有错误.
It's a patchwork of several tutorials while every of them threw the same error. My Magento installation is in html under project. Only thing that differs to all tutorials is, that I have no html/app/code/local
folder.
Composer install and behat --init run without errors.
修改: 我正在使用MAMP Pro,因此发现此问题.但是,将套接字文件链接到/tmp并不能解决我的问题.
I'm working with MAMP Pro, so I found this issue. But linking the socket file to /tmp did not fix my problem.
推荐答案
由于我使用了MAMP,因此我还必须为CLI配置它:
Since I use MAMP, I have to configure it for CLI as well:
export PATH=/Applications/MAMP/bin/php/php5.6.10/bin:$PATH
现在CLI使用了我的MAMP PHP版本,一切运行正常.
Now CLI uses my MAMP PHP version and everything runs well.
这篇关于为什么magento behat测试找不到我的数据库?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!