(WP-CLI)未创建Wordpress-Tests_Lib文件

时间:2015-10-06 19:38:52

标签: wordpress plugins proxy phpunit wp-cli

我正在尝试在Ubuntu 14.04上进行WordPress插件测试,我正在进行WP-CLI的设置,但是我无法下载必要的文件(包括/ 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中设置了代理。

非常感谢帮助。

2 个答案:

答案 0 :(得分:2)

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

  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. 再次运行install shell script命令。

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

答案 1 :(得分:0)

我遇到了同样的问题;按照此处的说明解决了这个问题: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是数据库用户,''包含密码。

更多资源:

相关问题