bash – wp-cli:无法在MAMP上运行phpunit

前端之家收集整理的这篇文章主要介绍了bash – wp-cli:无法在MAMP上运行phpunit前端之家小编觉得挺不错的,现在分享给大家,也给大家做个参考。
我跟着 plugin test setup/install instructions.我得到了wp脚本插件测试我的插件来运行.但是在下一步当我尝试运行bash bin / install-wp-tests.sh wordpress_test root”localhost最新我收到以下错误
  1. MysqLadmin: connect to server at 'localhost' Failed
  2. error: 'Can't connect to MysqL server on 'localhost' (61)'
  3. Check that MysqLd is running on localhost and that the port is 3306.
  4. You can check this by doing 'telnet localhost 3306'

我的本地wordpress网站正在运行MAMP(正在工作).我不知道这是否与安装脚本相关,因为我认为它正在创建一个临时数据库来运行测试…如果它使用内置的OSX或MysqLMysqL

这是wp –info的输出

  1. $./vendor/wp-cli/wp-cli/bin/wp --info
  2. PHP binary: /Applications/MAMP/bin/PHP/PHP5.6.10/bin/PHP
  3. PHP version: 5.6.10
  4. PHP.ini used: /Applications/MAMP/bin/PHP/PHP5.6.10/conf/PHP.ini
  5. WP-CLI root dir: /Applications/MAMP/htdocs/pipeline/wp-content/plugins/wp-github-pipeline/vendor/wp-cli/wp-cli
  6. WP-CLI global config:
  7. WP-CLI project config:
  8. WP-CLI version: 0.19.2

更新2
我发现原来MysqL没有安装…这就是为什么我无法连接!但现在是.我运行安装脚本,这是工作…

  1. $./vendor/wp-cli/wp-cli/bin/wp db tables
  2. wp_users
  3. wp_userMeta
  4. wp_posts
  5. wp_comments
  6. wp_links
  7. wp_options
  8. wp_postMeta
  9. wp_terms
  10. wp_term_taxonomy
  11. wp_term_relationships
  12. wp_commentMeta

但是当我运行PHPunit我得到这个:

  1. $PHPunit
  2. PHP Warning: MysqLi_real_connect(): (HY000/2002): No such file or directory in /private/tmp/wordpress/wp-includes/wp-db.PHP on line 1452
  3. PHP Stack trace:
  4. PHP 1. {main}() /private/tmp/wordpress-tests-lib/includes/install.PHP:0
  5. PHP 2. require_once() /private/tmp/wordpress-tests-lib/includes/install.PHP:21
  6. PHP 3. require_wp_db() /private/tmp/wordpress/wp-settings.PHP:79
  7. PHP 4. wpdb->__construct() /private/tmp/wordpress/wp-includes/load.PHP:350
  8. PHP 5. wpdb->db_connect() /private/tmp/wordpress/wp-includes/wp-db.PHP:649
  9. PHP 6. MysqLi_real_connect() /private/tmp/wordpress/wp-includes/wp-db.PHP:1452
  10.  
  11. Warning: MysqLi_real_connect(): (HY000/2002): No such file or directory in /private/tmp/wordpress/wp-includes/wp-db.PHP on line 1452

我的问题的一部分是,我不清楚是否wp-cli应该完全运行在native(cli)PHP / MysqL或MAMP的PHP / MysqL,或两者的某种组合.

更新4
我确定最后的问题是PHPunit需要安装在MAMP中,但是我正在从OSX运行…

  1. $which PHPunit
  2. /usr/bin/PHPunit

this gist提到.

更新6

原来你不能再使用梨来安装PHPunit了.所以我把它作为一个作曲家依赖在require-dev,但是当我运行那个版本我得到相同的错误

  1. $./vendor/PHPunit/PHPunit/PHPunit
  2. PHP Warning: MysqLi_real_connect(): (HY000/1045): Access denied for user 'root'@'localhost' (using password: NO) in /private/tmp/wordpress/wp-includes/wp-db.PHP on line 1452
  3. PHP Stack trace:
  4. PHP 1. {main}() /private/tmp/wordpress-tests-lib/includes/install.PHP:0
  5. PHP 2. require_once() /private/tmp/wordpress-tests-lib/includes/install.PHP:21
  6. PHP 3. require_wp_db() /private/tmp/wordpress/wp-settings.PHP:79
  7. PHP 4. wpdb->__construct() /private/tmp/wordpress/wp-includes/load.PHP:350
  8. PHP 5. wpdb->db_connect() /private/tmp/wordpress/wp-includes/wp-db.PHP:649
  9. PHP 6. MysqLi_real_connect() /private/tmp/wordpress/wp-includes/wp-db.PHP:1452
  10.  
  11. Warning: MysqLi_real_connect(): (HY000/1045): Access denied for user 'root'@'localhost' (using password: NO) in /private/tmp/wordpress/wp-includes/wp-db.PHP on line 1452

我甚至把它添加到我的路上,以确保…

  1. $which PHPunit
  2. /Applications/MAMP/htdocs/pipeline/wp-content/plugins/wp-github-pipeline/vendor/PHPunit/PHPunit/PHPunit

更新7

阅读this博客文章底部评论后,我看到安装脚本引用了OSX版本的MysqLadmin.我不知道这是否重要,但我在路径中添加了MAMPs版本,并重新运行安装脚本.似乎在/ tmp / anyway中安装wordpress文件.运行PHPunit时出现同样的错误

如果您使用MAMP,问题可能与您的MysqL服务器设置相关.确保在MAMP设置中选中允许网络访问选项:

更新1

在根目录中创建PHPinfo.PHP文件(通常是/ Applications / MAMP / htdocs for MAMP).粘贴以下内容

  1. <?PHP PHPinfo() ?>

然后检查加载的配置文件属性.在终端中使用nano或其他文本编辑器打开它.然后找到并将此3 propertiespdo_MysqL.default_socket,MysqL.default_socket,MysqLi.default_socket更改为您的套接文件.

参考http://maccrazy.com/lion-upgrade-killed-my-php-site-and-how-i-fixed-it

猜你在找的Bash相关文章