cannot run phpunit with wp-cli: could not find /wordpress-tests-lib/includes/functions.php, have you run bin/install-wp-tests.sh?

I'm trying hard to run PHP-Unit for a WordPress plugin idea using XAMPP for MacOS, but i'm just struggling so hard and just ran out of ideas about what to try, and I can't get rid of this error:

❯ phpunit
Could not find /var/folders/_f/4v8byddd4snc_0l9nsql33fc0000gn/t/wordpress-tests-lib/includes/functions.php, have you run bin/install-wp-tests.sh ?

I have navigated manually to that folder, which is installed --or not-- by this command through this bash file

bin/install-wp-tests.sh wordpress_mytest root root 127.0.0.1 latest

The thing is, bootstrap.php requires a WP_TESTS_DIR through

$_tests_dir = getenv( 'WP_TESTS_DIR' );
$_tests_dir = rtrim( sys_get_temp_dir(), '/\\' ) . '/wordpress-tests-lib';

And then it checks if functions.php exists here:

if ( ! file_exists( "{$_tests_dir}/includes/functions.php" ) ) {
echo "Could not find {$_tests_dir}/includes/functions.php, have you run bin/install-wp-tests.sh ?" . PHP_EOL; // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped
exit( 1 );

}

manually navigating to the path printing $_tests_dir, I found only these files:

❯ pwd
/var/folders/_f/4v8byddd4snc_0l9nsql33fc0000gn/t/wordpress-tests-lib

❯ ls

wp-tests-config.php     wp-tests-config.php.bak

What can I be missing here?

Any help or suggestion would be greatly appreciated.

Thank you!



Read more here: https://stackoverflow.com/questions/67929464/cannot-run-phpunit-with-wp-cli-could-not-find-wordpress-tests-lib-includes-fun

Content Attribution

This content was originally published by Eduardo Chaparro Alire at Recent Questions - Stack Overflow, and is syndicated here via their RSS feed. You can read the original post over there.

%d bloggers like this: