Update bootstrap.php to support themes
We should update phpunit-plugin-bootstrap.php to support theme THEME_GIT_PLUGIN_DEPENDENCIES since #150 was merged. Similar to how we activate WP_TEST_ACTIVATED_PLUGINS:
https://github.com/xwp/wp-dev-lib/blob/20eba62e831cf1db9e60a113b51e0280bd76b476/phpunit-plugin-bootstrap.php#L59-L72
Here's the bootstrap.php file I used to test the branch. I don't think we need support for THEME_GIT_PLUGIN_DEPENDENCIES inside phpunit-plugin-bootstrap.php. However, I do think we should add a phpunit-theme-bootstrap.php file to demonstrate how it works. The WP_TEST_ACTIVATED_PLUGINS constant is pulled from the phpunit.xml.dist file, which is the same data and sort of redundant but they serve slightly different purposes and I'm fairly certain out of scope from each other.
Also, we should add something similar to the phpunit-plugin.xml but for themes. In my version I added a WP_TEST_ACTIVATED_THEME constant that was used like so:
/**
* Activate the theme
*/
function _manually_load_theme() {
if ( defined( 'WP_TEST_ACTIVATED_THEME' ) ) {
switch_theme( WP_TEST_ACTIVATED_THEME );
}
}
tests_add_filter( 'muplugins_loaded', '_manually_load_theme' );
I don't think we need support for THEME_GIT_PLUGIN_DEPENDENCIES inside phpunit-plugin-bootstrap.php.
My thinking was that a generic sample bootstrap.php file could support both plugin and theme dependancies. What are the drawbacks of this approach?
I have the local theme folder named differently than the GitHub repo which is why WP_TEST_ACTIVATED_THEME doesn't work for me. I did this:
switch_theme( 'vip/' . basename( dirname( __DIR__ ) ) );
in bootstrap.php.