diff --git a/.env b/.env index ace9464317..2309631a5e 100644 --- a/.env +++ b/.env @@ -45,17 +45,21 @@ LOCAL_PHP_XDEBUG=false # Whether or not to enable Memcached. LOCAL_PHP_MEMCACHED=false +## # The database software to use. # # Supported values are `mysql` and `mariadb`. +## LOCAL_DB_TYPE=mysql +## # The database version to use. # # Defaults to 5.7 with the assumption that LOCAL_DB_TYPE is set to `mysql` above. # # When using `mysql`, see https://hub.docker.com/_/mysql/ for valid versions. # When using `mariadb`, see https://hub.docker.com/_/mariadb for valid versions. +## LOCAL_DB_VERSION=5.7 # The debug settings to add to `wp-config.php`. @@ -67,3 +71,10 @@ LOCAL_WP_ENVIRONMENT_TYPE=local # The URL to use when running e2e tests. WP_BASE_URL=http://localhost:${LOCAL_PORT} + +## +# The revision number of the WordPress Importer plugin to use when running unit tests. +# +# This should be an SVN revision number from the official plugin repository on wordpress.org. +## +WP_IMPORTER_REVISION=2387243 diff --git a/.github/workflows/phpunit-tests.yml b/.github/workflows/phpunit-tests.yml index 0d14901f5e..d6f1ed9bc2 100644 --- a/.github/workflows/phpunit-tests.yml +++ b/.github/workflows/phpunit-tests.yml @@ -24,7 +24,6 @@ jobs: # Performs the following steps: # - Cancels all previous workflow runs for pull requests that have not completed. # - Checks out the repository. - # - Checks out the WordPress Importer plugin (needed for the Core PHPUnit tests). # - Logs debug information about the runner container. # - Installs NodeJS 14. # - Sets up caching for NPM. @@ -47,9 +46,6 @@ jobs: - name: Checkout repository uses: actions/checkout@v2 - - name: Checkout the WordPress Importer plugin - run: svn checkout -r 2387243 https://plugins.svn.wordpress.org/wordpress-importer/trunk/ tests/phpunit/data/plugins/wordpress-importer - - name: Log debug information run: | echo "$GITHUB_REF" diff --git a/tools/local-env/scripts/install.js b/tools/local-env/scripts/install.js index 32371ee190..2bce37b03b 100644 --- a/tools/local-env/scripts/install.js +++ b/tools/local-env/scripts/install.js @@ -20,6 +20,8 @@ wp_cli( `config set WP_ENVIRONMENT_TYPE ${process.env.LOCAL_WP_ENVIRONMENT_TYPE} // Move wp-config.php to the base directory, so it doesn't get mixed up in the src or build directories. renameSync( 'src/wp-config.php', 'wp-config.php' ); +install_wp_importer(); + // Read in wp-tests-config-sample.php, edit it to work with our config, then write it to wp-tests-config.php. const testConfig = readFileSync( 'wp-tests-config-sample.php', 'utf8' ) .replace( 'youremptytestdbnamehere', 'wordpress_develop_tests' ) @@ -45,3 +47,12 @@ wait_on( { resources: [ `tcp:localhost:${process.env.LOCAL_PORT}`] } ) function wp_cli( cmd ) { execSync( `docker-compose run --rm cli ${cmd}`, { stdio: 'inherit' } ); } + +/** + * Downloads the WordPress Importer plugin for use in tests. + */ +function install_wp_importer() { + const test_plugin_directory = 'tests/phpunit/data/plugins/wordpress-importer'; + + execSync( `docker-compose exec -T php rm -rf ${test_plugin_directory} && svn checkout -r ${process.env.WP_IMPORTER_REVISION} https://plugins.svn.wordpress.org/wordpress-importer/trunk/ ${test_plugin_directory}`, { stdio: 'inherit' } ); +}