Testing Plugin – Install plugin dependencies in testing enviroment
Testing Plugin – Install plugin dependencies in testing enviroment
Testing Plugin – Install plugin dependencies in testing enviroment
PHPUnit Testing Installation Issue
Figured out that it was the @runTestsInSeparateProcesses annotation in the test class that was causing the error. Not sure why that would cause it. Once I removed it, the test completed successfully. ./vendor/bin/phpunit –group ajax Installing… Running as single site… To run multisite, use -c tests/phpunit/multisite.xml Not running ms-files tests. To execute these, use –group …
Unit Test ignores stubbed method second time around in a dataProvider
If you look at the source of add_settings_error(), you will see that the errors are stored in the $wp_settings_errors global. So in your tearDown() function, you can do this: $GLOBALS[‘wp_settings_errors’] = array(); Also, don’t forget to call parent::tearDown(). I sometimes forget, and it can lead to strange behavior. 😉
You may not have the xdebug PHP extension enabled. When I run the tests without xdebug enabled on PHPUnit 4.8.26, I get this message: Warning: The Xdebug extension is not loaded No code coverage will be generated. It looks like VVV comes with xdebug though, so it is probably enabled by default. But perhaps you …
Integration test – remove the mu plugins in the test
enter code hereActually come to find out after further testing, these new set of folders, wordpress and wordpress-test-lib, that are now in the new directory /var/folders/xq/zdm3rwn…. do indeed still work properly for the unit testing. Hope that helps someone else wondering about this same issue. In all the docs for these installs that I have …
I found out why. here is the solution: you have to activate the plugin in the tests / bootstrap.php file: $GLOBALS[ ‘wp_tests_options’ ] = array( ‘active_plugins’ => array( ‘YOUR-PLUGIN/YOUR-PLUGIN.php’ ) )
return defined(‘WC_VERSION’); should fix since defined() accepts a string as parameter. https://www.php.net/manual/en/function.defined.php If you use: require_once($_SERVER[‘DOCUMENT_ROOT’].’/wp-load.php’); adjusting your path if the installation is in a subrdir you load all the WP environment including active plugins etc