6

I'm trying to do WordPress Plugin Testing on Ubuntu 14.04 and I'm going through the setup of WP-CLI but I'm not able to download the necessary files (includes/functions.php).

This is the command I'm using:

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

This is the output:

+ 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.

On using the phpunit command it throws an error:

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

I'm at the office so I think the firewall could be blocking this command, though I have set a proxy in /etc/environment.

Help is appreciated.

Andrew C.
  • 421
  • 5
  • 15

2 Answers2

13

I had this problem and here is what you might try:

  1. Confirm that /tmp/wordpress-tests-lib is missing the includes directory.

  2. Confirm that you have svn installed on the machine. If not run sudo apt-get install subversion

  3. Delete the /tmp/wordpress-tests-lib folder

  4. Inside your plugin directory open up the bin/install-wp-tests.sh file and remove the quiet flag on the Subversion call. Change this line:

    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. Run the install shell script command again.

You should now be able to run PHPUnit and see the one default test passes.

sprise
  • 391
  • 3
  • 8
  • Thanks, it hasn't solved the problem. I'm dealing with a third-party repo, but I'm pretty sure the code I've added is correct regardless of this test-suite issue – MrMesees Sep 19 '16 at 18:59
  • 2
    I had this exact error, and this solution (simply removing `--quiet` from the install script) solved the problem for me. – Luke Carbis Jun 04 '19 at 03:58
  • Wow - yes this worked - does anyone know _why_ removing `--quiet` makes a difference? – Phil Birnie Mar 10 '21 at 03:11
0

I was having the same issue; resolved it by following the instructions here: https://github.com/wp-cli/wp-cli/wiki/Plugin-Unit-Tests . Specifically, I needed to initialize the testing environment.

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

where wordpress_test is test database, root is DB user and '' contains password.

Further Resources:

Pea
  • 431
  • 7
  • 9