Closed MikeiLL closed 7 years ago
I am still confused about this, man.
phpunit.xml.dist
in the top level dir of this repository clone, next to my-plugin
.phpunit.xml
file in my-plugin
.phpunit.xml.dist
<phpunit
bootstrap="./my-plugin/tests/bootstrap.php"
backupGlobals="false"
colors="true"
convertErrorsToExceptions="true"
convertNoticesToExceptions="true"
convertWarningsToExceptions="true"
>
<testsuites>
<testsuite>
<directory prefix="test-" suffix=".php">./my-plugin/tests/</directory>
</testsuite>
</testsuites>
</phpunit>
my-plugin/tests/bootstrap.php
<?php
/**
* PHPUnit bootstrap file
*
* @package My Plugin
*/
$_tests_dir = getenv( 'WP_TESTS_DIR' ); if ( ! $_tests_dir ) { $_tests_dir = '/tmp/wordpress-tests-lib'; }
// Give access to tests_add_filter() function. require_once $_tests_dir . '/includes/functions.php';
/**
// Start up the WP testing environment. require $_tests_dir . '/includes/bootstrap.php';
I think the README in this awesome repo could guide newbies like me a little further and would be honored if I can help.
Thanks, I'll merge this PR and also think about ways to improve the docs.
As for your testing issue, I intended your plugin code to live at the root of your plugin or theme repo. (Or, in other words, take docker-compose.yml
and drop it into the root of your plugin/theme repo.)
That said, there's nothing here incompatible with plugin code living in a subdirectory. I just followed your instructions and replicated your structure on a branch of this repo:
https://github.com/chriszarate/docker-compose-wordpress/tree/subdir
Everything works fine and the docker-compose exec wordpress tests
command works as expected.
All works as expected for me as well. I am hoping I can help document the how-to of doing it this way. Mainly still trying to wrap my head around how it works. Thank you.
Disambiguate location of environment variable for other newbies.