(WP-CLI)没有创建Wordpress-Tests_Lib文件



我正在尝试在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 == Darwin ]]
+ 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中设置了一个代理。

感谢帮助

我遇到了这个问题,你可以试试:

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

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

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

  4. 在你的插件目录中打开bin/install-wp-tests.sh文件并删除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命令。

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

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

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

其中wordpress_test为test database, root为DB user, ''为password。

进一步资源:

  • http://dlh01.info/wcto2014//
  • https://pippinsplugins.com/series/unit-tests-wordpress-plugins/
  • http://code.tutsplus.com/tutorials/the -初学者指南- -单元测试- - -单元测试- wp - 25728

最新更新