【问题标题】:(WP-CLI) Wordpress-Tests_Lib files not being created(WP-CLI) 未创建 Wordpress-Tests_Lib 文件
【发布时间】:2015-10-06 19:38:52
【问题描述】:

我正在尝试在 Ubuntu 14.04 上进行 WordPress 插件测试,我正在完成 WP-CLI 的设置,但我无法下载必要的文件(includes/functions.php)。

这是我正在使用的命令:

bash bin/install-wp-tests.sh wordpress_test root '' localhost latest

这是输出:

+ install_wp
+ '[' -d /tmp/wordpress/ ']'
+ return
+ install_test_suite
++ uname -s
+ [[ Linux == \D\a\r\w\i\n ]]
+ local ioption=-i
+ '[' '!' -d /tmp/wordpress-tests-lib ']'
+ cd /tmp/wordpress-tests-lib
+ '[' '!' -f wp-tests-config.php ']'
+ download https://develop.svn.wordpress.org/trunk/wp-tests-config-sample.php /tmp/wordpress-tests-lib/wp-tests-config.php
++ which curl
+ '[' /opt/lampp/bin/curl ']'
+ curl -s https://develop.svn.wordpress.org/trunk/wp-tests-config-sample.php
+ sed -i 's:dirname( __FILE__ ) . '\''/src/'\'':'\''/tmp/wordpress/'\'':' /tmp/wordpress-tests-lib/wp-tests-config.php
+ sed -i s/youremptytestdbnamehere/wordpress_test/ /tmp/wordpress-tests-lib/wp-tests-config.php
+ sed -i s/yourusernamehere/root/ /tmp/wordpress-tests-lib/wp-tests-config.php
+ sed -i s/yourpasswordhere// /tmp/wordpress-tests-lib/wp-tests-config.php
+ sed -i 's|localhost|localhost|' /tmp/wordpress-tests-lib/wp-tests-config.php
+ install_db
+ PARTS=(${DB_HOST//\:/ })
+ local PARTS
+ local DB_HOSTNAME=localhost
+ local DB_SOCK_OR_PORT=
+ local EXTRA=
+ '[' -z localhost ']'
++ echo
++ grep -e '^[0-9]\{1,\}$'
+ '[' ']'
+ '[' -z ']'
+ '[' -z localhost ']'
+ EXTRA=' --host=localhost --protocol=tcp'
+ mysqladmin create wordpress_test --user=root --password= --host=localhost --protocol=tcp
Warning: Using a password on the command line interface can be insecure.

在使用 phpunit 命令时会引发错误:

Fatal error: require_once(): Failed opening required '/tmp/wordpress-tests-lib/includes/functions.php' (include_path='.:/opt/lampp/lib/php')

我在办公室,所以我认为防火墙可能会阻止此命令,尽管我在 /etc/environment 中设置了代理。

感谢您的帮助。

【问题讨论】:

  • 无法用 PHPUnit 测试 Wordpress。
  • @zdenek-machek - 你的说法是错误的。 PHPUnit 用于测试核心,可与 WP-CLI 配合使用。
  • 您最终找到解决方案了吗?

标签: wordpress plugins proxy phpunit wp-cli


【解决方案1】:

我遇到了这个问题,您可以尝试以下方法:

  1. 确认/tmp/wordpress-tests-lib 缺少includes 目录。

  2. 确认您的机器上安装了 svn。如果不运行sudo apt-get install subversion

  3. 删除/tmp/wordpress-tests-lib文件夹

  4. 在您的插件目录中打开bin/install-wp-tests.sh 文件并删除Subversion 调用上的quiet 标志。更改此行:

    svn co --quiet https://develop.svn.wordpress.org/${WP_TESTS_TAG}/tests/phpunit/includes/ $WP_TESTS_DIR/includes
    
    to
    
    svn co https://develop.svn.wordpress.org/${WP_TESTS_TAG}/tests/phpunit/includes/ $WP_TESTS_DIR/includes
    
  5. 再次运行安装 shell 脚本命令。

您现在应该能够运行 PHPUnit 并看到一个默认测试通过。

【讨论】:

  • 谢谢,还没有解决问题。我正在处理第三方存储库,但我很确定我添加的代码是正确的,无论这个测试套件问题如何
  • 我遇到了这个确切的错误,这个解决方案(只需从安装脚本中删除 --quiet)为我解决了这个问题。
  • 哇 - 是的,这行得通 - 有人知道为什么删除--quiet会有所不同吗?
【解决方案2】:

我遇到了同样的问题;按照此处的说明解决它:https://github.com/wp-cli/wp-cli/wiki/Plugin-Unit-Tests。具体来说,我需要初始化测试环境。

bash bin/install-wp-tests.sh wordpress_test root '' localhost latest

wordpress_test 是测试数据库,root 是数据库用户,'' 包含密码。

更多资源:

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 2022-10-14
    • 1970-01-01
    • 1970-01-01
    • 2017-02-05
    • 2015-08-11
    • 1970-01-01
    • 2016-10-24
    • 2012-12-03
    相关资源
    最近更新 更多