(WP-CLI) Wordpress-Tests_Lib files not being created
Asked Answered
K

2

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.

Kira answered 6/10, 2015 at 19:38 Comment(3)
Wordpress can't be tested with PHPUnit.Hexamethylenetetramine
@zdenek-machek - Your statement is wrong. PHPUnit is used to test core and can be used in conjunction with WP-CLI.Trehala
Did you end up finding a solution for this?Palma
F
16

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.

Fisc answered 15/4, 2016 at 18:55 Comment(3)
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 issueCrimea
I had this exact error, and this solution (simply removing --quiet from the install script) solved the problem for me.Chandos
Wow - yes this worked - does anyone know why removing --quiet makes a difference?Offcenter
T
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:

Trehala answered 2/11, 2015 at 4:51 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.