chriszarate / docker-compose-wordpress

An example Docker Compose setup for WordPress plugin or theme development.
162 stars 54 forks source link

Update README.md #4

Closed MikeiLL closed 7 years ago

MikeiLL commented 7 years ago

Disambiguate location of environment variable for other newbies.

MikeiLL commented 7 years ago

I am still confused about this, man.

  1. I have phpunit.xml.dist in the top level dir of this repository clone, next to my-plugin.
  2. There is no phpunit.xml file in my-plugin.
  3. PHPUNIT_TEST_DIR: "/var/www/html/wp-content/plugins/my-plugin"
  4. 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>
    1. 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.
chriszarate commented 7 years ago

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.

MikeiLL commented 7 years ago

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.