From 87580ed6b808c6b2034747e9a8aa8ce225c63e47 Mon Sep 17 00:00:00 2001 From: Adam Silverstein Date: Wed, 18 Nov 2020 07:49:22 -0700 Subject: [PATCH 01/37] Environment GD/Imagick check available & supported formats. --- prepare.php | 2 ++ 1 file changed, 2 insertions(+) diff --git a/prepare.php b/prepare.php index 5be3988..97b4bc6 100644 --- a/prepare.php +++ b/prepare.php @@ -51,6 +51,8 @@ \$env = array( 'php_version' => phpversion(), 'php_modules' => array(), + 'gd_info' => extension_loaded( 'gd' ) ? gd_info() : 'unavailable', + 'Imagick_info' => extension_loaded( 'imagick' ) ? Imagick::queryFormats() : 'unavailable' 'system_utils' => array(), 'mysql_version' => trim( shell_exec( 'mysql --version' ) ), 'os_name' => trim( shell_exec( 'uname -s' ) ), From ab833e26a07aaab274e90ba5789d099309908eb3 Mon Sep 17 00:00:00 2001 From: Adam Silverstein Date: Thu, 19 Nov 2020 11:46:36 -0700 Subject: [PATCH 02/37] Add image info in `functions.php` plus cleanup naming, add missing comma. --- functions.php | 2 ++ prepare.php | 2 +- 2 files changed, 3 insertions(+), 1 deletion(-) diff --git a/functions.php b/functions.php index 62cfe8c..5962d0a 100644 --- a/functions.php +++ b/functions.php @@ -187,6 +187,8 @@ function get_env_details() { $env = array( 'php_version' => phpversion(), 'php_modules' => array(), + 'gd_info' => extension_loaded( 'gd' ) ? gd_info() : 'unavailable', + 'imagick_info' => extension_loaded( 'imagick' ) ? Imagick::queryFormats() : 'unavailable', 'system_utils' => array(), 'mysql_version' => trim( shell_exec( 'mysql --version' ) ), 'os_name' => trim( shell_exec( 'uname -s' ) ), diff --git a/prepare.php b/prepare.php index 97b4bc6..ca9ea08 100644 --- a/prepare.php +++ b/prepare.php @@ -52,7 +52,7 @@ 'php_version' => phpversion(), 'php_modules' => array(), 'gd_info' => extension_loaded( 'gd' ) ? gd_info() : 'unavailable', - 'Imagick_info' => extension_loaded( 'imagick' ) ? Imagick::queryFormats() : 'unavailable' + 'imagick_info' => extension_loaded( 'imagick' ) ? Imagick::queryFormats() : 'unavailable', 'system_utils' => array(), 'mysql_version' => trim( shell_exec( 'mysql --version' ) ), 'os_name' => trim( shell_exec( 'uname -s' ) ), From 965d2bfc82615bad84870d3aa76c8d80a833293e Mon Sep 17 00:00:00 2001 From: Adam Silverstein Date: Wed, 23 Dec 2020 09:21:00 -0700 Subject: [PATCH 03/37] Default to empty array for gd/imagick info. --- functions.php | 4 ++-- prepare.php | 4 ++-- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/functions.php b/functions.php index 5962d0a..7d8df46 100644 --- a/functions.php +++ b/functions.php @@ -187,8 +187,8 @@ function get_env_details() { $env = array( 'php_version' => phpversion(), 'php_modules' => array(), - 'gd_info' => extension_loaded( 'gd' ) ? gd_info() : 'unavailable', - 'imagick_info' => extension_loaded( 'imagick' ) ? Imagick::queryFormats() : 'unavailable', + 'gd_info' => extension_loaded( 'gd' ) ? gd_info() : array(), + 'imagick_info' => extension_loaded( 'imagick' ) ? Imagick::queryFormats() : array(), 'system_utils' => array(), 'mysql_version' => trim( shell_exec( 'mysql --version' ) ), 'os_name' => trim( shell_exec( 'uname -s' ) ), diff --git a/prepare.php b/prepare.php index ca9ea08..5697a7a 100644 --- a/prepare.php +++ b/prepare.php @@ -51,8 +51,8 @@ \$env = array( 'php_version' => phpversion(), 'php_modules' => array(), - 'gd_info' => extension_loaded( 'gd' ) ? gd_info() : 'unavailable', - 'imagick_info' => extension_loaded( 'imagick' ) ? Imagick::queryFormats() : 'unavailable', + 'gd_info' => extension_loaded( 'gd' ) ? gd_info() : array(), + 'imagick_info' => extension_loaded( 'imagick' ) ? Imagick::queryFormats() : array(), 'system_utils' => array(), 'mysql_version' => trim( shell_exec( 'mysql --version' ) ), 'os_name' => trim( shell_exec( 'uname -s' ) ), From d81bf2967e0a35e88475e5d5a22aaa5c578daf2f Mon Sep 17 00:00:00 2001 From: Brian Alexander <824344+ironprogrammer@users.noreply.github.com> Date: Fri, 12 Aug 2022 14:35:36 -0700 Subject: [PATCH 04/37] Pin node version to 14 In response to https://github.com/WordPress/phpunit-test-runner/issues/174#issuecomment-1181615065. --- .travis.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.travis.yml b/.travis.yml index c406a62..71890f8 100644 --- a/.travis.yml +++ b/.travis.yml @@ -1,6 +1,6 @@ language: php node_js: - - node + - 14 before_install: - npm install -g npm@latest From bd2af4f9af6e53b8cfab64757a4a102b20a7f2f7 Mon Sep 17 00:00:00 2001 From: Brian Alexander <824344+ironprogrammer@users.noreply.github.com> Date: Fri, 12 Aug 2022 14:36:32 -0700 Subject: [PATCH 05/37] Specify node version in README Follow-up to https://github.com/WordPress/hosting-handbook/commit/91663bfd3672b9721bc40402bdefd4bb50c900f7 --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index f6a3a55..c49ccb3 100644 --- a/README.md +++ b/README.md @@ -69,7 +69,7 @@ Prep environment: * PHP 5.6 or greater (to run scripts). * Utilities: `git` version 1.8.5 or greater, `rsync`, `wget`, `unzip`. -* Node.js including `npm` and `grunt` packages +* Node.js 14.x, including `npm` and `grunt` packages Test environment: From 4046232b17a1a74ad49bf073281bcc2edfa763ae Mon Sep 17 00:00:00 2001 From: Micah Wood Date: Fri, 17 Feb 2023 01:49:11 -0500 Subject: [PATCH 06/37] Allow workflow to be run on demand --- .github/workflows/tests.yml | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/.github/workflows/tests.yml b/.github/workflows/tests.yml index d3f46f2..7180747 100644 --- a/.github/workflows/tests.yml +++ b/.github/workflows/tests.yml @@ -20,6 +20,7 @@ on: # - cron: '0 0 * * *' # Every 30 minutes. # - cron: '0/30 * * * *' + workflow_dispatch: # Cancels all previous workflow runs for pull requests that have not completed. concurrency: @@ -42,7 +43,7 @@ jobs: test: name: Run Core PHPUnit tests runs-on: ubuntu-latest - + # Remove this line if Github Actions is your preferred means of running the tests. if: ${{ false }} From d1a48ad34cae8570e606a467c7957dac6a501021 Mon Sep 17 00:00:00 2001 From: Daniel Black Date: Thu, 8 Sep 2022 12:16:36 +1000 Subject: [PATCH 07/37] Use mysql version from server rather than mysql --version mysql --version is the version of the client program and not necessarly the server version. Get the version accurate for the reports generated. --- functions.php | 9 ++++++++- prepare.php | 10 +++++++--- 2 files changed, 15 insertions(+), 4 deletions(-) diff --git a/functions.php b/functions.php index b092569..17cfdf9 100644 --- a/functions.php +++ b/functions.php @@ -184,11 +184,14 @@ function upload_results( $results, $rev, $message, $env, $api_key ) { * Get the environmental details */ function get_env_details() { + $WPT_DB_HOST = getenv( 'WPT_DB_HOST' ) ? : 'localhost'; + $WPT_DB_USER = getenv( 'WPT_DB_USER' ); + $WPT_DB_PASSWORD = getenv( 'WPT_DB_PASSWORD' ); + $WPT_DB_NAME = getenv( 'WPT_DB_NAME' ); $env = array( 'php_version' => phpversion(), 'php_modules' => array(), 'system_utils' => array(), - 'mysql_version' => trim( shell_exec( 'mysql --version' ) ), 'os_name' => trim( shell_exec( 'uname -s' ) ), 'os_version' => trim( shell_exec( 'uname -r' ) ), ); @@ -214,6 +217,10 @@ function get_env_details() { $curl_bits = explode( PHP_EOL, str_replace( 'curl ', '', shell_exec( 'curl --version' ) ) ); $curl = array_shift( $curl_bits ); $env['system_utils']['curl'] = trim( $curl ); + $mysqli = new mysqli($WPT_DB_HOST, $WPT_DB_USER, $WPT_DB_PASSWORD, $WPT_DB_NAME); + $env['mysql_version'] = $mysqli->query("SELECT VERSION()")->fetch_row()[0]; + $mysqli->close(); + if ( class_exists( 'Imagick' ) ) { $imagick = new Imagick(); $version = $imagick->getVersion(); diff --git a/prepare.php b/prepare.php index 04b891b..f93158e 100644 --- a/prepare.php +++ b/prepare.php @@ -54,7 +54,6 @@ 'php_version' => phpversion(), 'php_modules' => array(), 'system_utils' => array(), - 'mysql_version' => trim( shell_exec( 'mysql --version' ) ), 'os_name' => trim( shell_exec( 'uname -s' ) ), 'os_version' => trim( shell_exec( 'uname -r' ) ), ); @@ -92,13 +91,18 @@ \$env['system_utils']['graphicsmagick'] = \$version[1]; } \$env['system_utils']['openssl'] = str_replace( 'OpenSSL ', '', trim( shell_exec( 'openssl version' ) ) ); +EOT; +$db_version = <<query("SELECT VERSION()")->fetch_row()[0]; +\$mysqli->close(); file_put_contents( __DIR__ . '/tests/phpunit/build/logs/env.json', json_encode( \$env, JSON_PRETTY_PRINT ) ); if ( 'cli' === php_sapi_name() && defined( 'WP_INSTALLING' ) && WP_INSTALLING ) { echo PHP_EOL; echo 'PHP version: ' . phpversion() . ' (' . realpath( \$_SERVER['_'] ) . ')' . PHP_EOL; echo PHP_EOL; } -EOT; +EODB; $logger_replace_string = '// ** Database settings ** //' . PHP_EOL; $system_logger = $logger_replace_string . $system_logger; $php_binary_string = 'define( \'WP_PHP_BINARY\', \''. $WPT_PHP_EXECUTABLE . '\' );'; @@ -112,7 +116,7 @@ $logger_replace_string => $system_logger, ); $contents = str_replace( array_keys( $search_replace ), array_values( $search_replace ), $contents ); -file_put_contents( $WPT_PREPARE_DIR . '/wp-tests-config.php', $contents ); +file_put_contents( $WPT_PREPARE_DIR . '/wp-tests-config.php', $contents . $db_version); // Now, install PHPUnit based on the test environment's PHP Version $php_version_cmd = $WPT_PHP_EXECUTABLE . " -r \"print PHP_MAJOR_VERSION . '.' . PHP_MINOR_VERSION . '.' . PHP_RELEASE_VERSION;\""; From 984235083badd0d71c6790e5b67cd45ca84ca925 Mon Sep 17 00:00:00 2001 From: Pascal Birchler Date: Thu, 25 May 2023 12:11:59 +0200 Subject: [PATCH 08/37] Report more PHP extensions --- prepare.php | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/prepare.php b/prepare.php index 04b891b..2c02d57 100644 --- a/prepare.php +++ b/prepare.php @@ -61,14 +61,21 @@ \$php_modules = array( 'bcmath', 'curl', + 'dom', + 'exif', 'filter', 'gd', + 'gettext', + 'gmagick', + 'iconv', + 'imagick', + 'intl', 'libsodium', + 'libxml', + 'mbstring', 'mcrypt', 'mod_xml', 'mysqli', - 'imagick', - 'gmagick', 'pcre', 'xml', 'xmlreader', From 9dfbabeeafea1a1c49b4a52231fc0748a70893bb Mon Sep 17 00:00:00 2001 From: Jonathan Desrosiers Date: Tue, 30 May 2023 14:53:52 -0400 Subject: [PATCH 09/37] Update all 3rd party GHA to the latest versions. --- .github/workflows/tests.yml | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/.github/workflows/tests.yml b/.github/workflows/tests.yml index 7180747..a71895b 100644 --- a/.github/workflows/tests.yml +++ b/.github/workflows/tests.yml @@ -64,16 +64,16 @@ jobs: steps: - name: Checkout repository - uses: actions/checkout@5a4ac9002d0be2fb38bd78e4b4dbde5606d7042f # v2.3.4 + uses: actions/checkout@8e5e7e5ab8b370d6c329ec480221332ada57f0ab # v3.5.2 - name: Set up PHP - uses: shivammathur/setup-php@947009a71769c25ab5292f073f5343624b7c879d # v2.12.0 + uses: shivammathur/setup-php@c5fc0d8281aba02c7fda07d3a70cc5371548067d # v2.25.2 with: php-version: '7.4' coverage: none - name: Install NodeJS - uses: actions/setup-node@25316bbc1f10ac9d8798711f44914b1cf3c4e954 # v2.4.0 + uses: actions/setup-node@64ed1c7eab4cce3362f8c340dee64e5eaeef8f7c # v3.6.0 with: node-version: 14 From 1bed364a4a678db80ccbc82c78d7165f1f2d91b2 Mon Sep 17 00:00:00 2001 From: Javier Casares Date: Sat, 11 Nov 2023 13:48:09 +0100 Subject: [PATCH 10/37] clean the variables --- package-lock.json | 6 ++++++ prepare.php | 26 ++++++++++++++++++++------ 2 files changed, 26 insertions(+), 6 deletions(-) create mode 100644 package-lock.json diff --git a/package-lock.json b/package-lock.json new file mode 100644 index 0000000..bac5db0 --- /dev/null +++ b/package-lock.json @@ -0,0 +1,6 @@ +{ + "name": "phpunit-test-runner", + "lockfileVersion": 2, + "requires": true, + "packages": {} +} diff --git a/prepare.php b/prepare.php index 2c02d57..773d3f0 100644 --- a/prepare.php +++ b/prepare.php @@ -10,12 +10,26 @@ check_required_env(); // Bring some environment variables into scope. -$WPT_PREPARE_DIR = getenv( 'WPT_PREPARE_DIR' ); -$WPT_SSH_CONNECT = getenv( 'WPT_SSH_CONNECT' ); -$WPT_SSH_OPTIONS = getenv( 'WPT_SSH_OPTIONS' ) ? : '-o StrictHostKeyChecking=no'; -$WPT_TEST_DIR = getenv( 'WPT_TEST_DIR' ); -$WPT_PHP_EXECUTABLE = getenv( 'WPT_PHP_EXECUTABLE' ) ? : 'php'; -$WPT_DEBUG = getenv( 'WPT_DEBUG' ); +$WPT_PREPARE_DIR = trim( getenv( 'WPT_PREPARE_DIR' ) ); +$WPT_SSH_CONNECT = trim( getenv( 'WPT_SSH_CONNECT' ) ); +$WPT_SSH_OPTIONS = trim( getenv( 'WPT_SSH_OPTIONS' ) ) ? : '-o StrictHostKeyChecking=no'; +$WPT_TEST_DIR = trim( getenv( 'WPT_TEST_DIR' ) ); +$WPT_PHP_EXECUTABLE = trim( getenv( 'WPT_PHP_EXECUTABLE' ) ) ? : 'php'; +$WPT_DEBUG_INI = getenv( 'WPT_DEBUG' ); +switch( $WPT_DEBUG_INI ) { + case 0: + case 'false' + case false: + default: + $WPT_DEBUG = false; + break; + case 1: + case 'true' + case true: + $WPT_DEBUG = true; + break; +} +unset( $WPT_DEBUG_INI ); // Set the ssh private key if it's set. $WPT_SSH_PRIVATE_KEY_BASE64 = getenv( 'WPT_SSH_PRIVATE_KEY_BASE64' ); From 96fbb55bc123638caff24de6dda458c6962fb7a6 Mon Sep 17 00:00:00 2001 From: Javier Casares Date: Sat, 11 Nov 2023 13:50:19 +0100 Subject: [PATCH 11/37] empty connect some times escapeshellarg sends '', so it fails. --- prepare.php | 15 +++++++++++---- 1 file changed, 11 insertions(+), 4 deletions(-) diff --git a/prepare.php b/prepare.php index 773d3f0..572b288 100644 --- a/prepare.php +++ b/prepare.php @@ -39,10 +39,17 @@ mkdir( getenv( 'HOME' ) . '/.ssh', 0777, true ); } file_put_contents( getenv( 'HOME' ) . '/.ssh/id_rsa', base64_decode( $WPT_SSH_PRIVATE_KEY_BASE64 ) ); - perform_operations( array( - 'chmod 600 ~/.ssh/id_rsa', - 'ssh -q ' . $WPT_SSH_OPTIONS . ' ' . escapeshellarg( $WPT_SSH_CONNECT ) . ' wp cli info', - ) ); + if( empty( $WPT_SSH_CONNECT ) ) { + perform_operations( array( + 'chmod 600 ~/.ssh/id_rsa', + 'wp cli info', + ) ); + } else { + perform_operations( array( + 'chmod 600 ~/.ssh/id_rsa', + 'ssh -q ' . $WPT_SSH_OPTIONS . ' ' . escapeshellarg( $WPT_SSH_CONNECT ) . ' wp cli info', + ) ); + } } // Create the preparation directory and fetch corresponding files From 23946dce02a33da210ea03e72cd64b66df0d54c4 Mon Sep 17 00:00:00 2001 From: Javier Casares Date: Sat, 11 Nov 2023 13:53:18 +0100 Subject: [PATCH 12/37] php extensions give more clear context --- prepare.php | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/prepare.php b/prepare.php index 572b288..cb16fa5 100644 --- a/prepare.php +++ b/prepare.php @@ -81,25 +81,39 @@ ); \$php_modules = array( 'bcmath', + 'ctype', 'curl', + 'date', 'dom', 'exif', + 'fileinfo', 'filter', + 'ftp', 'gd', 'gettext', 'gmagick', + 'hash', 'iconv', 'imagick', + 'imap', 'intl', + 'json', 'libsodium', 'libxml', 'mbstring', 'mcrypt', 'mod_xml', 'mysqli', + 'mysqlnd', + 'openssl', 'pcre', + 'pdo_mysql', + 'soap', + 'sockets', + 'sodium', 'xml', 'xmlreader', + 'zip', 'zlib', ); foreach( \$php_modules as \$php_module ) { From 9bd0a51b3dc08a1352bbd41e32a097bc6a0dfc4a Mon Sep 17 00:00:00 2001 From: Javier Casares Date: Sat, 11 Nov 2023 13:54:25 +0100 Subject: [PATCH 13/37] fix possible errors --- prepare.php | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/prepare.php b/prepare.php index cb16fa5..0145381 100644 --- a/prepare.php +++ b/prepare.php @@ -145,11 +145,11 @@ $system_logger = $logger_replace_string . $system_logger; $php_binary_string = 'define( \'WP_PHP_BINARY\', \''. $WPT_PHP_EXECUTABLE . '\' );'; $search_replace = array( - 'wptests_' => getenv( 'WPT_TABLE_PREFIX' ) ? : 'wptests_', - 'youremptytestdbnamehere' => getenv( 'WPT_DB_NAME' ), - 'yourusernamehere' => getenv( 'WPT_DB_USER' ), - 'yourpasswordhere' => getenv( 'WPT_DB_PASSWORD' ), - 'localhost' => getenv( 'WPT_DB_HOST' ), + 'wptests_' => trim( getenv( 'WPT_TABLE_PREFIX' ) ) ? : 'wptests_', + 'youremptytestdbnamehere' => trim( getenv( 'WPT_DB_NAME' ) ), + 'yourusernamehere' => trim( getenv( 'WPT_DB_USER' ) ), + 'yourpasswordhere' => trim( getenv( 'WPT_DB_PASSWORD' ) ), + 'localhost' => trim( getenv( 'WPT_DB_HOST' ) ), 'define( \'WP_PHP_BINARY\', \'php\' );' => $php_binary_string, $logger_replace_string => $system_logger, ); From cedd61b23d4ef6802c553af757fec7971cddc67e Mon Sep 17 00:00:00 2001 From: Javier Casares Date: Sat, 11 Nov 2023 13:55:46 +0100 Subject: [PATCH 14/37] minimum PHP 7.0 --- prepare.php | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/prepare.php b/prepare.php index 0145381..cc6b1c6 100644 --- a/prepare.php +++ b/prepare.php @@ -175,11 +175,11 @@ $env_php_version = '7.4'; } -if ( version_compare( $env_php_version, '5.6', '<' ) ) { - error_message( "The test runner is not compatible with PHP < 5.6." ); +if ( version_compare( $env_php_version, '7.0', '<' ) ) { + error_message( "The test runner is not compatible with PHP < 7.0." ); } -// If PHP version is 5.6-7.0, download PHPUnit 5.7 phar directly. +// If PHP version is 7.0, download PHPUnit 5.7 phar directly. if ( version_compare( $env_php_version, '7.1', '<' ) ) { perform_operations( array( 'wget -O ' . escapeshellarg( $WPT_PREPARE_DIR . '/phpunit.phar' ) . ' https://phar.phpunit.de/phpunit-5.7.phar', From d3b5258d786fd427bf1f1ce7c436bb5ba56f70e3 Mon Sep 17 00:00:00 2001 From: Javier Casares Date: Sat, 11 Nov 2023 13:57:54 +0100 Subject: [PATCH 15/37] fix the case --- prepare.php | 2 -- 1 file changed, 2 deletions(-) diff --git a/prepare.php b/prepare.php index cc6b1c6..9577bf7 100644 --- a/prepare.php +++ b/prepare.php @@ -19,13 +19,11 @@ switch( $WPT_DEBUG_INI ) { case 0: case 'false' - case false: default: $WPT_DEBUG = false; break; case 1: case 'true' - case true: $WPT_DEBUG = true; break; } From 98ccd60817ffe3759c362d85f3aeb13011f44415 Mon Sep 17 00:00:00 2001 From: Javier Casares Date: Sat, 11 Nov 2023 13:58:14 +0100 Subject: [PATCH 16/37] fix the case, again --- prepare.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/prepare.php b/prepare.php index 9577bf7..0d6e7ba 100644 --- a/prepare.php +++ b/prepare.php @@ -18,12 +18,12 @@ $WPT_DEBUG_INI = getenv( 'WPT_DEBUG' ); switch( $WPT_DEBUG_INI ) { case 0: - case 'false' + case 'false': default: $WPT_DEBUG = false; break; case 1: - case 'true' + case 'true': $WPT_DEBUG = true; break; } From 3b363106f401d974ed7e079230b6f22d00ca5474 Mon Sep 17 00:00:00 2001 From: Javier Casares Date: Sun, 12 Nov 2023 10:56:41 +0100 Subject: [PATCH 17/37] comments / PHPDocs some improved comments --- prepare.php | 195 ++++++++++++++++++++++++++++++++++++++++++++++------ 1 file changed, 173 insertions(+), 22 deletions(-) diff --git a/prepare.php b/prepare.php index 0d6e7ba..a004d37 100644 --- a/prepare.php +++ b/prepare.php @@ -1,42 +1,85 @@ trim( getenv( 'WPT_TABLE_PREFIX' ) ) ? : 'wptests_', 'youremptytestdbnamehere' => trim( getenv( 'WPT_DB_NAME' ) ), @@ -151,76 +238,140 @@ 'define( \'WP_PHP_BINARY\', \'php\' );' => $php_binary_string, $logger_replace_string => $system_logger, ); + +// Replace the placeholders in the wp-tests-config-sample.php file content with actual values. $contents = str_replace( array_keys( $search_replace ), array_values( $search_replace ), $contents ); + +// Write the modified content to the wp-tests-config.php file, which will be used by the test suite. file_put_contents( $WPT_PREPARE_DIR . '/wp-tests-config.php', $contents ); -// Now, install PHPUnit based on the test environment's PHP Version +/** + * Determines the PHP version of the test environment to ensure the correct version of PHPUnit is installed. + * It constructs a command that prints out the PHP version in a format compatible with PHPUnit's version requirements. + */ $php_version_cmd = $WPT_PHP_EXECUTABLE . " -r \"print PHP_MAJOR_VERSION . '.' . PHP_MINOR_VERSION . '.' . PHP_RELEASE_VERSION;\""; + +/** + * If an SSH connection string is provided, the command to determine the PHP version is modified + * to execute remotely over SSH. This is required if the test environment is not the local machine. + */ if ( ! empty( $WPT_SSH_CONNECT ) ) { + // The PHP version check command is prefixed with the SSH command, including SSH options, + // and the connection string, ensuring the command is executed on the remote machine. $php_version_cmd = 'ssh ' . $WPT_SSH_OPTIONS . ' ' . escapeshellarg( $WPT_SSH_CONNECT ) . ' ' . escapeshellarg( $php_version_cmd ); } +// Initialize return value variable for the exec function call. $retval = 0; + +/** + * Executes the constructed command to obtain the PHP version of the test environment. + * The output is stored in $env_php_version, and the return value of the command execution is stored in $retval. + */ $env_php_version = exec( $php_version_cmd, $output, $retval ); + +// Check if the command execution was successful by inspecting the return value. if ( $retval !== 0 ) { + // If the return value is not zero, an error occurred, and a message is logged. error_message( 'Could not retrieve the environment PHP Version.' ); } + +// Log the obtained PHP version for confirmation and debugging purposes. log_message( "Environment PHP Version: $env_php_version" ); -// If PHP Version is 8.X.X, set PHP Version to 7.4 for compatibility with core PHPUnit tests. + +/** + * Ensures compatibility with PHPUnit by adjusting the PHP version if needed. + * If the environment's PHP version is 8.x.x, it overrides the version to 7.4. + * This is because the core PHPUnit tests may not be compatible with PHP 8.x.x. + */ if ( substr( $env_php_version, 0 , 2 ) === '8.' ) { + // Log the occurrence of PHP version 8.x.x and the decision to use PHPUnit compatible with PHP 7.4 instead. log_message( 'Version 8.x.x Found. Downloading PHPUnit for PHP 7.4 instead for compatibility.' ); + + // Override the PHP version to 7.4 for PHPUnit compatibility. $env_php_version = '7.4'; } +/** + * Checks if the detected PHP version is below 7.0. + * The test runner requires PHP version 7.0 or above, and if the environment's PHP version + * is lower, it logs an error message and could terminate the script. + */ if ( version_compare( $env_php_version, '7.0', '<' ) ) { + // Logs an error message indicating the test runner's incompatibility with PHP versions below 7.0. error_message( "The test runner is not compatible with PHP < 7.0." ); } -// If PHP version is 7.0, download PHPUnit 5.7 phar directly. +/** + * Installs PHPUnit 5.7 directly if the PHP version is less than 7.1. + * PHPUnit 5.7 is the last version to support PHP 7.0. + */ if ( version_compare( $env_php_version, '7.1', '<' ) ) { + + // Download the PHPUnit phar file directly using wget. perform_operations( array( 'wget -O ' . escapeshellarg( $WPT_PREPARE_DIR . '/phpunit.phar' ) . ' https://phar.phpunit.de/phpunit-5.7.phar', ) ); -// Otherwise, use Composer to download PHPUnit to get further necessary dependencies. } else { - // First, check if composer is available. Download if not. - $composer_cmd = 'cd ' . escapeshellarg( $WPT_PREPARE_DIR ) . ' && '; + /** + * If the PHP version is 7.1 or greater, use Composer to manage PHPUnit and its dependencies. + * This allows for better dependency management and compatibility. + */ + // Check if Composer is installed and available in the PATH. + $composer_cmd = 'cd ' . escapeshellarg( $WPT_PREPARE_DIR ) . ' && '; $retval = 0; $composer_path = escapeshellarg( system( 'which composer', $retval ) ); + if ( $retval === 0 ) { + + // If Composer is available, prepare the command to use the Composer binary. $composer_cmd .= $composer_path . ' '; + } else { + + // If Composer is not available, download the Composer phar file. log_message( 'Local Composer not found. Downloading latest stable ...' ); perform_operations( array( 'wget -O ' . escapeshellarg( $WPT_PREPARE_DIR . '/composer.phar' ) . ' https://getcomposer.org/composer-stable.phar', ) ); + // Update the command to use the downloaded Composer phar file. $composer_cmd .= 'php composer.phar '; } - // Set Composer PHP environment, then run Composer. + // Set the PHP version for Composer to ensure compatibility and update dependencies. perform_operations( array( $composer_cmd . 'config platform.php ' . escapeshellarg( $env_php_version ), $composer_cmd . 'update', ) ); } -// Deliver all files to test environment. +/** + * If an SSH connection is configured, use rsync to transfer the prepared files to the remote test environment. + * The -r option for rsync enables recursive copying to handle directory structures. + * Additional rsync options may be included for more verbose output if debugging is enabled. + */ if ( ! empty( $WPT_SSH_CONNECT ) ) { + // Initialize rsync options with recursive copying. $rsync_options = '-r'; + // If debug mode is set to verbose, append 'v' to rsync options for verbose output. if ( 'verbose' === $WPT_DEBUG ) { $rsync_options = $rsync_options . 'v'; } + // Perform the rsync operation with the configured options and exclude patterns. + // This operation synchronizes the test environment with the prepared files, excluding version control directories + // and other non-essential files for test execution. perform_operations( array( 'rsync ' . $rsync_options . ' --exclude=".git/" --exclude="node_modules/" --exclude="composer.phar" -e "ssh ' . $WPT_SSH_OPTIONS . '" ' . escapeshellarg( trailingslashit( $WPT_PREPARE_DIR ) ) . ' ' . escapeshellarg( $WPT_SSH_CONNECT . ':' . $WPT_TEST_DIR ), ) ); } +// Log a success message indicating that the environment has been prepared. log_message( 'Success: Prepared environment.' ); From cff625f06370430ade842bf1573bd96aca33bf58 Mon Sep 17 00:00:00 2001 From: Javier Casares Date: Sun, 12 Nov 2023 11:01:18 +0100 Subject: [PATCH 18/37] ignore file --- .gitignore | 1 + 1 file changed, 1 insertion(+) diff --git a/.gitignore b/.gitignore index b1b8150..0721216 100644 --- a/.gitignore +++ b/.gitignore @@ -1,3 +1,4 @@ .DS_Store .env* vendor/ +package-lock.json \ No newline at end of file From 4117c3371f01ce02dd72e77728db90b59750e98b Mon Sep 17 00:00:00 2001 From: Javier Casares Date: Wed, 15 Nov 2023 09:20:31 +0100 Subject: [PATCH 19/37] improve the documentation --- cleanup.php | 46 ++++++++++++++++++++++++++++++++++------------ prepare.php | 1 + 2 files changed, 35 insertions(+), 12 deletions(-) diff --git a/cleanup.php b/cleanup.php index f2e03cf..77d9f61 100644 --- a/cleanup.php +++ b/cleanup.php @@ -1,30 +1,52 @@ Date: Wed, 15 Nov 2023 09:47:24 +0100 Subject: [PATCH 20/37] reorder the variables and clean them --- cleanup.php | 8 ++++---- test.php | 16 ++++++++++------ 2 files changed, 14 insertions(+), 10 deletions(-) diff --git a/cleanup.php b/cleanup.php index 77d9f61..49d6a0d 100644 --- a/cleanup.php +++ b/cleanup.php @@ -21,10 +21,10 @@ * These variables are used to configure SSH connections, file paths, and * executable commands needed for setting up the test environment. */ -$WPT_PREPARE_DIR = trim( getenv( 'WPT_PREPARE_DIR' ) ); -$WPT_SSH_CONNECT = trim( getenv( 'WPT_SSH_CONNECT' ) ); -$WPT_SSH_OPTIONS = trim( getenv( 'WPT_SSH_OPTIONS' ) ) ? : '-o StrictHostKeyChecking=no'; -$WPT_TEST_DIR = trim( getenv( 'WPT_TEST_DIR' ) ); +$WPT_PREPARE_DIR = trim( getenv( 'WPT_PREPARE_DIR' ) ); +$WPT_SSH_CONNECT = trim( getenv( 'WPT_SSH_CONNECT' ) ); +$WPT_SSH_OPTIONS = trim( getenv( 'WPT_SSH_OPTIONS' ) ) ? : '-o StrictHostKeyChecking=no'; +$WPT_TEST_DIR = trim( getenv( 'WPT_TEST_DIR' ) ); $WPT_RM_TEST_DIR_CMD = trim( getenv( 'WPT_RM_TEST_DIR_CMD' ) ) ? : 'rm -r ' . $WPT_TEST_DIR; /** diff --git a/test.php b/test.php index b4bff05..19172a7 100644 --- a/test.php +++ b/test.php @@ -6,16 +6,20 @@ require __DIR__ . '/functions.php'; -// Check required environment variables. +/** + * Check for the presence of required environment variables. + * This function should be defined in functions.php and should throw an + * exception or exit if any required variables are missing. + */ check_required_env(); -$WPT_SSH_CONNECT = getenv( 'WPT_SSH_CONNECT' ); -$WPT_TEST_DIR = getenv( 'WPT_TEST_DIR' ); -$WPT_SSH_OPTIONS = getenv( 'WPT_SSH_OPTIONS' ) ? : '-o StrictHostKeyChecking=no'; -$WPT_PHP_EXECUTABLE = getenv( 'WPT_PHP_EXECUTABLE' ) ? : 'php'; +$WPT_SSH_CONNECT = trim( getenv( 'WPT_SSH_CONNECT' ) ); +$WPT_TEST_DIR = trim( getenv( 'WPT_TEST_DIR' ) ); +$WPT_SSH_OPTIONS = trim( getenv( 'WPT_SSH_OPTIONS' ) ) ? : '-o StrictHostKeyChecking=no'; +$WPT_PHP_EXECUTABLE = trim( getenv( 'WPT_PHP_EXECUTABLE' ) ) ? : 'php'; // This uses `||` to run PHPUnit when it is downloaded manually (like for PHP 5.6-7.0) rather than through Composer. -$WPT_PHPUNIT_CMD = getenv( 'WPT_PHPUNIT_CMD' ) ? : 'cd ' . escapeshellarg( $WPT_TEST_DIR ) . ' && ' . $WPT_PHP_EXECUTABLE . ' ./vendor/phpunit/phpunit/phpunit --dont-report-useless-tests || ' . $WPT_PHP_EXECUTABLE . ' phpunit.phar --dont-report-useless-tests'; +$WPT_PHPUNIT_CMD = trim( getenv( 'WPT_PHPUNIT_CMD' ) ) ? : 'cd ' . escapeshellarg( $WPT_TEST_DIR ) . ' && ' . $WPT_PHP_EXECUTABLE . ' ./vendor/phpunit/phpunit/phpunit --dont-report-useless-tests || ' . $WPT_PHP_EXECUTABLE . ' phpunit.phar --dont-report-useless-tests'; // Run phpunit in the test environment. if ( ! empty( $WPT_SSH_CONNECT ) ) { From 513c77c42534865bcfffb3354867130b1842ea66 Mon Sep 17 00:00:00 2001 From: Javier Casares Date: Wed, 15 Nov 2023 09:55:45 +0100 Subject: [PATCH 21/37] comments and fixes --- prepare.php | 6 +++--- test.php | 19 +++++++++++++++---- 2 files changed, 18 insertions(+), 7 deletions(-) diff --git a/prepare.php b/prepare.php index e933c67..243197d 100644 --- a/prepare.php +++ b/prepare.php @@ -84,12 +84,12 @@ if( empty( $WPT_SSH_CONNECT ) ) { perform_operations( array( 'chmod 600 ~/.ssh/id_rsa', - 'wp cli info', + 'wp cli info' ) ); } else { perform_operations( array( 'chmod 600 ~/.ssh/id_rsa', - 'ssh -q ' . $WPT_SSH_OPTIONS . ' ' . escapeshellarg( $WPT_SSH_CONNECT ) . ' wp cli info', + 'ssh -q ' . $WPT_SSH_OPTIONS . ' ' . escapeshellarg( $WPT_SSH_CONNECT ) . ' wp cli info' ) ); } @@ -116,7 +116,7 @@ 'cd ' . escapeshellarg( $WPT_PREPARE_DIR . '/tests/phpunit/data/plugins/' ) . '; unzip wordpress-importer.zip; rm wordpress-importer.zip', // Change directory to the preparation directory, install npm dependencies, and build the project. - 'cd ' . escapeshellarg( $WPT_PREPARE_DIR ) . '; npm install && npm run build', + 'cd ' . escapeshellarg( $WPT_PREPARE_DIR ) . '; npm install && npm run build' ) ); diff --git a/test.php b/test.php index 19172a7..5de9072 100644 --- a/test.php +++ b/test.php @@ -1,9 +1,13 @@ Date: Wed, 15 Nov 2023 12:38:05 +0100 Subject: [PATCH 22/37] only use composer for PHPUnit --- prepare.php | 76 +++++++++++++++++------------------------------------ 1 file changed, 24 insertions(+), 52 deletions(-) diff --git a/prepare.php b/prepare.php index 243197d..522601d 100644 --- a/prepare.php +++ b/prepare.php @@ -278,21 +278,7 @@ } // Log the obtained PHP version for confirmation and debugging purposes. -log_message( "Environment PHP Version: $env_php_version" ); - - -/** - * Ensures compatibility with PHPUnit by adjusting the PHP version if needed. - * If the environment's PHP version is 8.x.x, it overrides the version to 7.4. - * This is because the core PHPUnit tests may not be compatible with PHP 8.x.x. - */ -if ( substr( $env_php_version, 0 , 2 ) === '8.' ) { - // Log the occurrence of PHP version 8.x.x and the decision to use PHPUnit compatible with PHP 7.4 instead. - log_message( 'Version 8.x.x Found. Downloading PHPUnit for PHP 7.4 instead for compatibility.' ); - - // Override the PHP version to 7.4 for PHPUnit compatibility. - $env_php_version = '7.4'; -} +log_message( 'Environment PHP Version: ' . $env_php_version ); /** * Checks if the detected PHP version is below 7.0. @@ -301,57 +287,43 @@ */ if ( version_compare( $env_php_version, '7.0', '<' ) ) { // Logs an error message indicating the test runner's incompatibility with PHP versions below 7.0. - error_message( "The test runner is not compatible with PHP < 7.0." ); + error_message( 'The test runner is not compatible with PHP < 7.0.' ); } /** - * Installs PHPUnit 5.7 directly if the PHP version is less than 7.1. - * PHPUnit 5.7 is the last version to support PHP 7.0. + * Use Composer to manage PHPUnit and its dependencies. + * This allows for better dependency management and compatibility. */ -if ( version_compare( $env_php_version, '7.1', '<' ) ) { - - // Download the PHPUnit phar file directly using wget. - perform_operations( array( - 'wget -O ' . escapeshellarg( $WPT_PREPARE_DIR . '/phpunit.phar' ) . ' https://phar.phpunit.de/phpunit-5.7.phar', - ) ); - -} else { - - /** - * If the PHP version is 7.1 or greater, use Composer to manage PHPUnit and its dependencies. - * This allows for better dependency management and compatibility. - */ - // Check if Composer is installed and available in the PATH. - $composer_cmd = 'cd ' . escapeshellarg( $WPT_PREPARE_DIR ) . ' && '; - $retval = 0; - $composer_path = escapeshellarg( system( 'which composer', $retval ) ); - - if ( $retval === 0 ) { - - // If Composer is available, prepare the command to use the Composer binary. - $composer_cmd .= $composer_path . ' '; +// Check if Composer is installed and available in the PATH. +$composer_cmd = 'cd ' . escapeshellarg( $WPT_PREPARE_DIR ) . ' && '; +$retval = 0; +$composer_path = escapeshellarg( system( 'which composer', $retval ) ); - } else { +if ( $retval === 0 ) { - // If Composer is not available, download the Composer phar file. - log_message( 'Local Composer not found. Downloading latest stable ...' ); + // If Composer is available, prepare the command to use the Composer binary. + $composer_cmd .= $composer_path . ' '; - perform_operations( array( - 'wget -O ' . escapeshellarg( $WPT_PREPARE_DIR . '/composer.phar' ) . ' https://getcomposer.org/composer-stable.phar', - ) ); +} else { - // Update the command to use the downloaded Composer phar file. - $composer_cmd .= 'php composer.phar '; - } + // If Composer is not available, download the Composer phar file. + log_message( 'Local Composer not found. Downloading latest stable ...' ); - // Set the PHP version for Composer to ensure compatibility and update dependencies. perform_operations( array( - $composer_cmd . 'config platform.php ' . escapeshellarg( $env_php_version ), - $composer_cmd . 'update', + 'wget -O ' . escapeshellarg( $WPT_PREPARE_DIR . '/composer.phar' ) . ' https://getcomposer.org/composer-stable.phar', ) ); + + // Update the command to use the downloaded Composer phar file. + $composer_cmd .= 'php composer.phar '; } +// Set the PHP version for Composer to ensure compatibility and update dependencies. +perform_operations( array( + $composer_cmd . 'config platform.php ' . escapeshellarg( $env_php_version ), + $composer_cmd . 'update', +) ); + /** * If an SSH connection is configured, use rsync to transfer the prepared files to the remote test environment. * The -r option for rsync enables recursive copying to handle directory structures. From 9c2e12939d670feb5f872af2fb9b42ab4ad973ad Mon Sep 17 00:00:00 2001 From: Javier Casares Date: Wed, 15 Nov 2023 15:35:55 +0100 Subject: [PATCH 23/37] add the verbose option --- prepare.php | 3 +++ 1 file changed, 3 insertions(+) diff --git a/prepare.php b/prepare.php index 522601d..b5066d5 100644 --- a/prepare.php +++ b/prepare.php @@ -43,6 +43,9 @@ case 'true': $WPT_DEBUG = true; break; + case 'verbose': + $WPT_DEBUG = 'verbose'; + break; default: $WPT_DEBUG = false; break; From 4a0c32cb784a15276839d9d9624bbfe10ccf0e98 Mon Sep 17 00:00:00 2001 From: Javier Casares Date: Wed, 15 Nov 2023 15:37:37 +0100 Subject: [PATCH 24/37] everything is composer now --- test.php | 13 +++++++++++-- 1 file changed, 11 insertions(+), 2 deletions(-) diff --git a/test.php b/test.php index 5de9072..decdd9e 100644 --- a/test.php +++ b/test.php @@ -27,8 +27,17 @@ $WPT_SSH_OPTIONS = trim( getenv( 'WPT_SSH_OPTIONS' ) ) ? : '-o StrictHostKeyChecking=no'; $WPT_PHP_EXECUTABLE = trim( getenv( 'WPT_PHP_EXECUTABLE' ) ) ? : 'php'; -// This uses `||` to run PHPUnit when it is downloaded manually (like for PHP 5.6-7.0) rather than through Composer. -$WPT_PHPUNIT_CMD = trim( getenv( 'WPT_PHPUNIT_CMD' ) ) ? : 'cd ' . escapeshellarg( $WPT_TEST_DIR ) . ' && ' . $WPT_PHP_EXECUTABLE . ' ./vendor/phpunit/phpunit/phpunit --dont-report-useless-tests || ' . $WPT_PHP_EXECUTABLE . ' phpunit.phar --dont-report-useless-tests'; +/** + * Determines the PHPUnit command to execute the test suite. + * Retrieves the PHPUnit command from the environment variable 'WPT_PHPUNIT_CMD'. If the environment + * variable is not set or is empty, it constructs a default command using the PHP executable path and + * the test directory path from environment variables, appending parameters to the PHPUnit call to + * avoid reporting useless tests. + */ +$WPT_PHPUNIT_CMD = trim( getenv( 'WPT_PHPUNIT_CMD' ) ); +if( empty( $WPT_PHPUNIT_CMD ) ) { + $WPT_PHPUNIT_CMD = 'cd ' . escapeshellarg( $WPT_TEST_DIR ) . ' && ' . $WPT_PHP_EXECUTABLE . ' ./vendor/phpunit/phpunit/phpunit --dont-report-useless-tests'; +} // If an SSH connection string is provided, prepend the SSH command to the PHPUnit execution command. if ( ! empty( $WPT_SSH_CONNECT ) ) { From ce33ba4e3e49129d9e6cc6c8258fd8dd065ca75d Mon Sep 17 00:00:00 2001 From: Javier Casares Date: Wed, 15 Nov 2023 15:39:06 +0100 Subject: [PATCH 25/37] some report improvements - clean the env data - add documentation - upload only if APIKey - if not, shows the result --- report.php | 155 ++++++++++++++++++++++++++++++++++++++++++++++------- 1 file changed, 135 insertions(+), 20 deletions(-) diff --git a/report.php b/report.php index 7384886..530f5c2 100644 --- a/report.php +++ b/report.php @@ -1,50 +1,139 @@ Date: Wed, 15 Nov 2023 15:41:12 +0100 Subject: [PATCH 26/37] delete the file... --- package-lock.json | 6 ------ 1 file changed, 6 deletions(-) delete mode 100644 package-lock.json diff --git a/package-lock.json b/package-lock.json deleted file mode 100644 index bac5db0..0000000 --- a/package-lock.json +++ /dev/null @@ -1,6 +0,0 @@ -{ - "name": "phpunit-test-runner", - "lockfileVersion": 2, - "requires": true, - "packages": {} -} From eba4af65c0ba07ff37188c468ebf2c05e1b135e2 Mon Sep 17 00:00:00 2001 From: Javier Casares Date: Wed, 15 Nov 2023 15:46:39 +0100 Subject: [PATCH 27/37] delete the file --- package-lock.json | 6 ------ 1 file changed, 6 deletions(-) delete mode 100644 package-lock.json diff --git a/package-lock.json b/package-lock.json deleted file mode 100644 index bac5db0..0000000 --- a/package-lock.json +++ /dev/null @@ -1,6 +0,0 @@ -{ - "name": "phpunit-test-runner", - "lockfileVersion": 2, - "requires": true, - "packages": {} -} From 559984cdcb1a57dd09353e1101d0cdc8d22efbc7 Mon Sep 17 00:00:00 2001 From: Javier Casares Date: Wed, 15 Nov 2023 16:27:14 +0100 Subject: [PATCH 28/37] certificate validation - local certificate validation - fix the verbose --- .env.default | 7 ++++++- prepare.php | 14 +++++++++++--- report.php | 2 -- 3 files changed, 17 insertions(+), 6 deletions(-) diff --git a/.env.default b/.env.default index 848e9c9..e2942ac 100644 --- a/.env.default +++ b/.env.default @@ -59,4 +59,9 @@ export WPT_SSH_PRIVATE_KEY_BASE64= # Output logging # Use 'verbose' to increase verbosity -export WPT_DEBUG= \ No newline at end of file +export WPT_DEBUG= + +# Certificate validation +# Use 1 to validate, and 0 to not validate +export WPT_CERTIFICATE_VALIDATION=1 + diff --git a/prepare.php b/prepare.php index b5066d5..53b6f03 100644 --- a/prepare.php +++ b/prepare.php @@ -28,6 +28,7 @@ $WPT_SSH_OPTIONS = trim( getenv( 'WPT_SSH_OPTIONS' ) ) ? : '-o StrictHostKeyChecking=no'; $WPT_TEST_DIR = trim( getenv( 'WPT_TEST_DIR' ) ); $WPT_PHP_EXECUTABLE = trim( getenv( 'WPT_PHP_EXECUTABLE' ) ) ? : 'php'; +$WPT_CERTIFICATE_VALIDATION = trim( getenv( 'WPT_CERTIFICATE_VALIDATION' ) ); /** * Determines if the debug mode is enabled based on the 'WPT_DEBUG' environment variable. @@ -41,8 +42,6 @@ break; case 1: case 'true': - $WPT_DEBUG = true; - break; case 'verbose': $WPT_DEBUG = 'verbose'; break; @@ -98,6 +97,15 @@ } +/** + * Don't validate the TLS certificate + * Useful for local environments + */ +$certificate_validation = ''; +if( ! $WPT_CERTIFICATE_VALIDATION ) { + $certificate_validation .= ' --no-check-certificate'; +} + /** * Performs a series of operations to set up the test environment. This includes creating a preparation directory, * cloning the WordPress development repository, downloading the WordPress importer plugin, and preparing the environment with npm. @@ -113,7 +121,7 @@ 'git clone --depth=1 https://github.com/WordPress/wordpress-develop.git ' . escapeshellarg( $WPT_PREPARE_DIR ), // Download the WordPress importer plugin zip file to the specified plugins directory. - 'wget -O ' . escapeshellarg( $WPT_PREPARE_DIR . '/tests/phpunit/data/plugins/wordpress-importer.zip' ) . ' https://downloads.wordpress.org/plugin/wordpress-importer.zip', + 'wget -O ' . escapeshellarg( $WPT_PREPARE_DIR . '/tests/phpunit/data/plugins/wordpress-importer.zip' ) . ' https://downloads.wordpress.org/plugin/wordpress-importer.zip' . $certificate_validation, // Change directory to the plugin directory, unzip the WordPress importer plugin, and remove the zip file. 'cd ' . escapeshellarg( $WPT_PREPARE_DIR . '/tests/phpunit/data/plugins/' ) . '; unzip wordpress-importer.zip; rm wordpress-importer.zip', diff --git a/report.php b/report.php index 530f5c2..32de8ff 100644 --- a/report.php +++ b/report.php @@ -41,8 +41,6 @@ break; case 1: case 'true': - $WPT_DEBUG = true; - break; case 'verbose': $WPT_DEBUG = 'verbose'; break; From 6fe66e95cf8f8220eb846c331374e484fb02e40e Mon Sep 17 00:00:00 2001 From: Javier Casares Date: Wed, 15 Nov 2023 17:08:29 +0100 Subject: [PATCH 29/37] add the new php modules --- functions.php | 25 +++++++++++++++++++++++-- 1 file changed, 23 insertions(+), 2 deletions(-) diff --git a/functions.php b/functions.php index b092569..6a074de 100644 --- a/functions.php +++ b/functions.php @@ -194,18 +194,39 @@ function get_env_details() { ); $php_modules = array( 'bcmath', + 'ctype', 'curl', + 'date', + 'dom', + 'exif', + 'fileinfo', 'filter', + 'ftp', 'gd', + 'gettext', + 'gmagick', + 'hash', + 'iconv', + 'imagick', + 'imap', + 'intl', + 'json', 'libsodium', + 'libxml', + 'mbstring', 'mcrypt', 'mod_xml', 'mysqli', - 'imagick', - 'gmagick', + 'mysqlnd', + 'openssl', 'pcre', + 'pdo_mysql', + 'soap', + 'sockets', + 'sodium', 'xml', 'xmlreader', + 'zip', 'zlib', ); foreach( $php_modules as $php_module ) { From 5f5020adf17d99ea5e8bc675698b97607eb50dfa Mon Sep 17 00:00:00 2001 From: Javier Casares Date: Wed, 15 Nov 2023 19:18:16 +0100 Subject: [PATCH 30/37] add the favor and groups --- .env.default | 11 +++++++++++ test.php | 38 +++++++++++++++++++++++++++++++++++++- 2 files changed, 48 insertions(+), 1 deletion(-) diff --git a/.env.default b/.env.default index e2942ac..84de84c 100644 --- a/.env.default +++ b/.env.default @@ -65,3 +65,14 @@ export WPT_DEBUG= # Use 1 to validate, and 0 to not validate export WPT_CERTIFICATE_VALIDATION=1 +# WordPress flavor +# 0 = WordPress (simple version) +# 1 = WordPress Multisite +export WPT_FLAVOR=1 + +# Extra tests (groups) +# 0 = none +# 1 = ajax +# 2 = ms-files +# 3 = external-http +export WPT_EXTRATESTS=0 diff --git a/test.php b/test.php index decdd9e..9ef110e 100644 --- a/test.php +++ b/test.php @@ -27,6 +27,42 @@ $WPT_SSH_OPTIONS = trim( getenv( 'WPT_SSH_OPTIONS' ) ) ? : '-o StrictHostKeyChecking=no'; $WPT_PHP_EXECUTABLE = trim( getenv( 'WPT_PHP_EXECUTABLE' ) ) ? : 'php'; +// Uses the flavor (usually to test WordPress Multisite) +$WPT_FLAVOR_INI = trim( getenv( 'WPT_FLAVOR' ) ); +switch( $WPT_FLAVOR_INI ) { + case 0: + $WPT_FLAVOR_TXT = ''; // Simple WordPress + break; + case 1: + $WPT_FLAVOR_TXT = ' -c tests/phpunit/multisite.xml'; // WordPress Multisite + break; + default: + $WPT_FLAVOR_TXT = ''; + break; +} +unset( $WPT_FLAVOR_INI ); + +// Uses the flavor (usually to test WordPress Multisite) +$WPT_EXTRATESTS_INI = trim( getenv( 'WPT_EXTRATESTS' ) ); +switch( $WPT_EXTRATESTS_INI ) { + case 0: + $WPT_EXTRATESTS_TXT = ''; // no extra tests + break; + case 1: + $WPT_EXTRATESTS_TXT = ' --group ajax'; // ajax tests + break; + case 2: + $WPT_EXTRATESTS_TXT = ' --group ms-files'; // ms-files tests + break; + case 3: + $WPT_EXTRATESTS_TXT = ' --group external-http'; // external-http tests + break; + default: + $WPT_EXTRATESTS_TXT = ''; + break; +} +unset( $WPT_EXTRATESTS_INI ); + /** * Determines the PHPUnit command to execute the test suite. * Retrieves the PHPUnit command from the environment variable 'WPT_PHPUNIT_CMD'. If the environment @@ -36,7 +72,7 @@ */ $WPT_PHPUNIT_CMD = trim( getenv( 'WPT_PHPUNIT_CMD' ) ); if( empty( $WPT_PHPUNIT_CMD ) ) { - $WPT_PHPUNIT_CMD = 'cd ' . escapeshellarg( $WPT_TEST_DIR ) . ' && ' . $WPT_PHP_EXECUTABLE . ' ./vendor/phpunit/phpunit/phpunit --dont-report-useless-tests'; + $WPT_PHPUNIT_CMD = 'cd ' . escapeshellarg( $WPT_TEST_DIR ) . ' && ' . $WPT_PHP_EXECUTABLE . ' ./vendor/phpunit/phpunit/phpunit --dont-report-useless-tests' . $WPT_FLAVOR_TXT; } // If an SSH connection string is provided, prepend the SSH command to the PHPUnit execution command. From 5eb4929c467e6e72be8598e151db2841001174f6 Mon Sep 17 00:00:00 2001 From: Javier Casares Date: Wed, 15 Nov 2023 19:21:11 +0100 Subject: [PATCH 31/37] fix (forget something) --- test.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/test.php b/test.php index 9ef110e..f5c7551 100644 --- a/test.php +++ b/test.php @@ -72,7 +72,7 @@ */ $WPT_PHPUNIT_CMD = trim( getenv( 'WPT_PHPUNIT_CMD' ) ); if( empty( $WPT_PHPUNIT_CMD ) ) { - $WPT_PHPUNIT_CMD = 'cd ' . escapeshellarg( $WPT_TEST_DIR ) . ' && ' . $WPT_PHP_EXECUTABLE . ' ./vendor/phpunit/phpunit/phpunit --dont-report-useless-tests' . $WPT_FLAVOR_TXT; + $WPT_PHPUNIT_CMD = 'cd ' . escapeshellarg( $WPT_TEST_DIR ) . ' && ' . $WPT_PHP_EXECUTABLE . ' ./vendor/phpunit/phpunit/phpunit --dont-report-useless-tests' . $WPT_FLAVOR_TXT . $WPT_EXTRATESTS_TXT; } // If an SSH connection string is provided, prepend the SSH command to the PHPUnit execution command. From 2a1cc5a52e2dbd023793325d4044f2da65760335 Mon Sep 17 00:00:00 2001 From: Federico Alvarez <32086536+fedealvz@users.noreply.github.com> Date: Thu, 14 Dec 2023 15:59:01 -0300 Subject: [PATCH 32/37] Update README.md Fixed links and update of requirements --- README.md | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/README.md b/README.md index c49ccb3..6bc67cc 100644 --- a/README.md +++ b/README.md @@ -4,7 +4,7 @@ Thanks for running the WordPress PHPUnit test suite on your infrastructure. We a If you haven't already, [please first read through the "Getting Started" documentation](https://make.wordpress.org/hosting/test-results-getting-started/). -The test suite runner is designed to be used without any file modification. Configuration happens with a series of environment variables (see [.env.default](.env.default) for an annotated overview). Use the [repository wiki](../../wiki) to document implementation details, to avoid README conflicts with the upstream. +The test suite runner is designed to be used without any file modification. Configuration happens with a series of environment variables (see [.env.default](.env.default) for an annotated overview). At a high level, the test suite runner: @@ -67,13 +67,13 @@ Both the prep and test environments must meet some basic requirements. Prep environment: -* PHP 5.6 or greater (to run scripts). +* PHP 7.x or greater (to run scripts). * Utilities: `git` version 1.8.5 or greater, `rsync`, `wget`, `unzip`. -* Node.js 14.x, including `npm` and `grunt` packages +* Node.js 16.x, including `npm` and `grunt` packages Test environment: -* PHP 5.6 or greater with Phar support enabled (for PHPUnit). +* PHP 7.x or greater with Phar support enabled (for PHPUnit). * MySQL or MariaDB with access to a writable database. * Writable filesystem for the entire test directory (see [#40910](https://core.trac.wordpress.org/ticket/40910)). * Run with a non-root user, both for security and practical purposes (see [#44233](https://core.trac.wordpress.org/ticket/44233#comment:34)/[#46577](https://core.trac.wordpress.org/ticket/46577)). @@ -110,7 +110,7 @@ The [`cleanup.php`](cleanup.php) step: ## Contributing -tk +If you have questions about the process or run into test failures along the way, please [open an issue in the project repository](https://github.com/wordpress/phpunit-test-runner/issues) and we’ll help diagnose/get the documentation updated. Alternatively, you can also pop into the `#hosting-community` channel on [WordPress.org Slack](https://make.wordpress.org/chat/) for help. ## License From 6635b8a6e8d0d50d7319f158de480f000698fc1a Mon Sep 17 00:00:00 2001 From: Javier Casares Date: Wed, 31 Jan 2024 10:13:02 +0100 Subject: [PATCH 33/37] Updated README --- README.md | 393 ++++++++++++++++++++++++++++++++++++++++++++++-------- 1 file changed, 336 insertions(+), 57 deletions(-) diff --git a/README.md b/README.md index c49ccb3..beb752d 100644 --- a/README.md +++ b/README.md @@ -1,10 +1,10 @@ -# phpunit-test-runner +# PHPUnit Test Runner Thanks for running the WordPress PHPUnit test suite on your infrastructure. We appreciate you helping to ensure WordPress’s compatibility for your users. -If you haven't already, [please first read through the "Getting Started" documentation](https://make.wordpress.org/hosting/test-results-getting-started/). +If you haven't already, [please first read through the "Getting Started" documentation](https://make.wordpress.org/hosting/handbook/tests/). -The test suite runner is designed to be used without any file modification. Configuration happens with a series of environment variables (see [.env.default](.env.default) for an annotated overview). Use the [repository wiki](../../wiki) to document implementation details, to avoid README conflicts with the upstream. +The test suite runner is designed to be used without any file modification. Configuration happens with a series of environment variables (see [.env.default](.env.default) for an annotated overview). At a high level, the test suite runner: @@ -13,7 +13,7 @@ At a high level, the test suite runner: 3. Reports the PHPUnit test results to WordPress.org 4. Cleans up the test suite environment. -## Configuring +## Setup The test suite runner can be used in one of two ways: @@ -24,94 +24,373 @@ The test runner is configured through environment variables, documented in [`.en With a direct Git clone, you can: - # Copy the default .env file. - cp .env.default .env - # Edit the .env file to define your variables. - vim .env - # Load your variables into scope. - source .env +```bash +# Copy the default .env file. +cp .env.default .env +# Edit the .env file to define your variables. +vim .env +# Load your variables into scope. +source .env +``` In a CI service, you can set these environment variables through the service's web console. Importantly, the `WPT_SSH_CONNECT` environment variable determines whether the test suite is run locally or against a remote environment. Concurrently run tests in the same environment by appending build ids to the test directory and table prefix: - export WPT_TEST_DIR=wp-test-runner-$TRAVIS_BUILD_NUMBER - export WPT_TABLE_PREFIX=wptests_$TRAVIS_BUILD_NUMBER\_ +```bash +export WPT_TEST_DIR=wp-test-runner-$TRAVIS_BUILD_NUMBER +export WPT_TABLE_PREFIX=wptests_$TRAVIS_BUILD_NUMBER\_ +``` Connect to a remote environment over SSH by having the CI job provision the SSH key: - # 1. Create a SSH key pair for the controller to use - ssh-keygen -t rsa -b 4096 -C "travis@travis-ci.org" - # 2. base64 encode the private key for use with the environment variable - cat ~/.ssh/id_rsa | base64 --wrap=0 - # 3. Append id_rsa.pub to authorized_keys so the CI service can SSH in - cat ~/.ssh/id_rsa.pub >> ~/.ssh/authorized_keys +```bash +# 1. Create a SSH key pair for the controller to use +ssh-keygen -t rsa -b 4096 -C "travis@travis-ci.org" +# 2. base64 encode the private key for use with the environment variable +cat ~/.ssh/id_rsa | base64 --wrap=0 +# 3. Append id_rsa.pub to authorized_keys so the CI service can SSH in +cat ~/.ssh/id_rsa.pub >> ~/.ssh/authorized_keys +``` Use a more complex SSH connection process by creating a SSH alias: - # 1. Add the following to ~/.ssh/config to create a 'wpt' alias - Host wpt - Hostname 123.45.67.89 - User wpt - Port 1234 - # 2. Use 'wpt' wherever you might normally use a SSH connection string - ssh wpt +```bash +# 1. Add the following to ~/.ssh/config to create a 'wpt' alias +Host wpt + Hostname 123.45.67.89 + User wpt + Port 1234 +# 2. Use 'wpt' wherever you might normally use a SSH connection string +ssh wpt +``` ## Running -The test suite runner is run in four steps. +The test suite runner is run in four steps. This explanation is for the local execution. -### 0. Requirements +### Requirements -Both the prep and test environments must meet some basic requirements. +To use the Runner, the following is required (testing WordPress 6.5): -Prep environment: - -* PHP 5.6 or greater (to run scripts). -* Utilities: `git` version 1.8.5 or greater, `rsync`, `wget`, `unzip`. -* Node.js 14.x, including `npm` and `grunt` packages +- Server / hosting (infrastructure) with the usual configuration you use +- A database where you can test (tables will be created and destroyed several times) +- PHP 7.0+ (view ) +- MySQL 5.5+ / MariaDB 10.0+ +- NodeJS 20.x / npm 10.x / grunt +- PHP Composer +- Git, RSync, WGet, UnZip Test environment: -* PHP 5.6 or greater with Phar support enabled (for PHPUnit). -* MySQL or MariaDB with access to a writable database. -* Writable filesystem for the entire test directory (see [#40910](https://core.trac.wordpress.org/ticket/40910)). -* Run with a non-root user, both for security and practical purposes (see [#44233](https://core.trac.wordpress.org/ticket/44233#comment:34)/[#46577](https://core.trac.wordpress.org/ticket/46577)). +- Writable filesystem for the entire test directory (see [#40910](https://core.trac.wordpress.org/ticket/40910)). +- Run with a non-root user, both for security and practical purposes (see [#44233](https://core.trac.wordpress.org/ticket/44233#comment:34)/[#46577](https://core.trac.wordpress.org/ticket/46577)). + +#### Database creation + +_This is an example for MySQL / MariaDB._ + +```sql +CREATE DATABASE wordpressdatabase CHARACTER SET = utf8mb4 COLLATE = utf8mb4_general_ci; +GRANT ALL ON wordpressdatabase.* TO 'wordpressusername'@'localhost' IDENTIFIED BY 'wordpresspassword'; +GRANT ALL ON wordpressdatabase.* TO 'wordpressusername'@'127.0.0.1' IDENTIFIED BY 'wordpresspassword'; +FLUSH PRIVILEGES; +``` + +#### NodeJS installation + +_This is an example for Debian / Ubuntu._ + +```bash +curl -fsSL https://deb.nodesource.com/setup_20.x | sudo -E bash - +sudo apt -y install nodejs +sudo npm install -g npm@latest +nodejs --version +npm --version +``` + +#### PHP Composer + +_This is an example for Debian / Ubuntu._ + +```bash +curl -sS https://getcomposer.org/installer -o composer-setup.php +php composer-setup.php --install-dir=/usr/local/bin --filename=composer +composer --version +``` + +#### Git + +_This is an example for Debian / Ubuntu._ + +```bash +apt -y install git +git --version +``` + +### Installing the Test Runner + +First, download the software. This example uses `/home/wptestrunner/` folder, but set the best for this environment. + +```bash +cd /home/wptestrunner/ +git clone https://github.com/WordPress/phpunit-test-runner.git +cd phpunit-test-runner/ +``` + +The next step will be to configure the environment. To do this, make a copy of the example file and then configure it. + +```bash +cp .env.default .env +vim .env +``` + +The content (in summary form) can be something like this: + +```bash +### +# Configuration environment variables used by the test runner +# +# # Create a copy for your local environment +# $ cp .env.default .env +# +# # Make any necessary changes to the default values +# $ vim .env +# +# # Load your variables into your environment +# $ source .env +### + +# Path to the directory where files can be prepared before being delivered to the environment. +export WPT_PREPARE_DIR=/tmp/wp-test-runner + +# Path to the directory where the WordPress develop checkout can be placed and tests can be run. +# When running tests in the same environment, set WPT_TEST_DIR to WPT_PREPARE_DIR +export WPT_TEST_DIR=/tmp/wp-test-runner + +# API key to authenticate with the reporting service in 'username:password' format. +export WPT_REPORT_API_KEY= + +# (Optionally) define an alternate reporting URL +export WPT_REPORT_URL= + +# Credentials for a database that can be written to and reset. +# WARNING!!! This database will be destroyed between tests. Only use safe database credentials. +# Please note that you must escape _or_ refrain from using # as special character in your credentials. +export WPT_DB_NAME= +export WPT_DB_USER= +export WPT_DB_PASSWORD= +export WPT_DB_HOST= + +# (Optionally) set a custom table prefix to permit concurrency against the same database. +export WPT_TABLE_PREFIX=${WPT_TABLE_PREFIX-wptests_} + +# (Optionally) define the PHP executable to be called +export WPT_PHP_EXECUTABLE=${WPT_PHP_EXECUTABLE-php} + +# (Optionally) define the PHPUnit command execution call. +# Use if `php phpunit.phar` can't be called directly for some reason. +export WPT_PHPUNIT_CMD= + +# (Optionally) define the command execution to remove the test directory +# Use if `rm -r` can't be called directly for some reason. +export WPT_RM_TEST_DIR_CMD= + +# SSH connection string (can also be an alias). +# Leave empty if tests are meant to run in the same environment. +export WPT_SSH_CONNECT= + +# Any options to be passed to the SSH connection +# Defaults to '-o StrictHostKeyChecking=no' +export WPT_SSH_OPTIONS= + +# SSH private key, base64 encoded. +export WPT_SSH_PRIVATE_KEY_BASE64= + +# Output logging +# Use 'verbose' to increase verbosity +export WPT_DEBUG= + +# Certificate validation +# Use 1 to validate, and 0 to not validate +export WPT_CERTIFICATE_VALIDATION=1 + +# WordPress flavor +# 0 = WordPress (simple version) +# 1 = WordPress Multisite +export WPT_FLAVOR=1 + +# Extra tests (groups) +# 0 = none +# 1 = ajax +# 2 = ms-files +# 3 = external-http +export WPT_EXTRATESTS=0 +``` + +Configure the folder where the WordPress software downloads and the database accesses will be made in order to prepare the tests. + +### Preparing the environment + +Before performing the first test, let’s update all the components. This process can be run before each test in this environment if wanted to keep it up to date, although it will depend more if it is in a production environment. + +```bash +cd /home/wptestrunner/phpunit-test-runner/ +git pull +source .env +git checkout master +``` + +If you want to check a different branch, you can change it doing: + +```bash +git checkout example-branch +``` + +## Preparing the test + +Now there is the environment ready, run the test preparation. + +```bash +php prepare.php +``` + +The system will run a long series of installations, configurations and compilations of different elements in order to prepare the test. If warnings and warnings come out you should not worry too much, as it is quite normal. At the end of the process it will warn you if it needs something it doesn’t have. If it works, you should see something like this at the end: + +``` +Success: Prepared environment. +``` + +Now that the environment has been prepared, the next step is to run the tests for the first time. + +### Running the test + +Now that the environment is ready, let’s run the tests. To do this, execute the file that will perform it. + +```bash +php test.php +``` + +What do the symbols mean? + +`.` → Each dot means that the test has been passed correctly. + +`S` → It means the test has been skipped. This is usually because these tests are only valid in certain configurations. + +`F` → Means that the test has failed. Information about why this happened is displayed at the end. + +`E` → It means that the test has failed due to a PHP error, which can be an error, warning or notice. + +`I` → Means that the test has been marked as incomplete. + +If you follow these steps, everything should work perfectly and not make any mistakes. In case you get any error, it may be normal due to some missing adjustment or extension of PHP, among others. We recommend that you adjust the configuration until it works correctly. After all, this tool is to help you improve the optimal configuration for WordPress in that infrastructure. + +### Creating a report + +Even if the test has failed, a report will be made. The first one shows the information about our environment. Among the most important elements are the extensions that are commonly used in WordPress and some utilities that are also generally useful. + +```bash +cat /tmp/wp-test-runner/tests/phpunit/build/logs/env.json +``` + +The content of this file is somewhat similar to this: -### 1. Prepare +```bash +{ + "php_version": "7.4.5", + "php_modules": { + "bcmath": false, + "curl": "7.4.5", + "filter": "7.4.5", + "gd": false, + "libsodium": false, + "mcrypt": false, + "mod_xml": false, + "mysqli": "7.4.5", + "imagick": false, + "pcre": "7.4.5", + "xml": "7.4.5", + "xmlreader": "7.4.5", + "zlib": "7.4.5" + }, + "system_utils": { + "curl": "7.58.0 (x86_64-pc-linux-gnu) libcurl\/7.58.0 OpenSSL\/1.1.1g zlib\/1.2.11 libidn2\/2.3.0 libpsl\/0.19.1 (+libidn2\/2.0.4) nghttp2\/1.30.0 librtmp\/2.3", + "ghostscript": "", + "imagemagick": false, + "openssl": "1.1.1g 21 Apr 2020" + }, + "mysql_version": "mysql Ver 15.1 Distrib 10.4.12-MariaDB, for debian-linux-gnu (x86_64) using readline 5.2", + "os_name": "Linux", + "os_version": "4.15.0-20-generic" +} +``` -The [`prepare.php`](prepare.php) step: +In addition to this report, a definitive file with all the information of what happened in the tests. This is the one that includes all the tests that are made (more than 10,000) giving information of the time that they take to be executed, problems that have arisen… -1. Extracts the base64-encoded SSH private key, if necessary. -2. Clones the master branch of the WordPress develop git repo into the preparation directory. -3. Downloads `phpunit.phar` to the preparation directory. -4. Generates `wp-tests-config.php` and puts it into the preparation directory. -5. Delivers the prepared test directory to the test environment. +```bash +cat /tmp/wp-test-runner/tests/phpunit/build/logs/junit.xml +``` -### 2. Test +At this point we can generate the reports by sending them to WordPress.org, if necessary. Even if you haven’t included the WordPress user (see below for how to create it), you can still run this file. -The [`test.php`](test.php) step: +```bash +php report.php +``` -1. Calls `php phpunit.phar` to produce `tests/phpunit/build/logs/junit.xml`. +### Cleaning up the environment for other tests -### 3. Report +Having the tests working, all that remains is to delete all the files that have been created so that we can start over. To do this, execute the following command: -The [`report.php`](report.php) step: +```bash +php cleanup.php +``` -1. Processes PHPUnit XML log into a JSON blob. -2. Sends the JSON to WordPress.org. +### Automatic running -### 4. Cleanup +The best way to run this test is to create a cron that runs everything. Having in mind that the tests can overlap, the best way can be using a systemd timer. -The [`cleanup.php`](cleanup.php) step: +```bash +cat > /etc/systemd/system/wordpressphpunittestrunner.service << EOF +[Unit] +Description=WordPress PHPUnit Test Runner +[Service] +Type=oneshot +ExecStart=cd /home/wptestrunner/phpunit-test-runner/ && source .env && php prepare.php && php test.php && php report.php && php cleanup.php +User=wptestrunner +Group=wptestrunner +EOF +``` -1. Resets the database. -2. Deletes all files delivered to the test environment. +```bash +cat > /etc/systemd/system/wordpressphpunittestrunner.timer << EOF +[Unit] +Description=WordPress PHPUnit Test Runner +[Timer] +OnCalendar=*-*-* *:*:00 +Persistent=true +[Install] +WantedBy=timers.target +EOF +``` + +```bash +systemctl daemon-reload +systemctl enable wordpressphpunittestrunner.timer +systemctl start wordpressphpunittestrunner.timer +systemctl status wordpressphpunittestrunner.timer +``` + +If you want to check how is everything working... + +```bash +journalctl -u wordpressphpunittestrunner.timer +journalctl -n 120 -u wordpressphpunittestrunner.service +``` ## Contributing -tk +If you have questions about the process or run into test failures along the way, please [open an issue in the project repository](https://github.com/WordPress/phpunit-test-runner/issues) and we’ll help diagnose/get the documentation updated. Alternatively, you can also pop into the `#hosting` channel on [WordPress.org Slack](https://make.wordpress.org/chat/) for help. ## License -See [LICENSE](LICENSE) for project license. +See [LICENSE](LICENSE) for project license. \ No newline at end of file From 7ce6982bf9d969a92d27d7197fdcefab4eb6a1c6 Mon Sep 17 00:00:00 2001 From: Javier Casares Date: Wed, 7 Feb 2024 08:08:24 +0100 Subject: [PATCH 34/37] fix --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index beb752d..046dfad 100644 --- a/README.md +++ b/README.md @@ -53,7 +53,7 @@ cat ~/.ssh/id_rsa | base64 --wrap=0 cat ~/.ssh/id_rsa.pub >> ~/.ssh/authorized_keys ``` -Use a more complex SSH connection process by creating a SSH alias: +Use a more complex SSH connection process by creating an SSH alias: ```bash # 1. Add the following to ~/.ssh/config to create a 'wpt' alias From 87cfd71496d7ce15e92311f9356974c90a5a1678 Mon Sep 17 00:00:00 2001 From: Javier Casares Date: Wed, 7 Feb 2024 08:09:30 +0100 Subject: [PATCH 35/37] Improve PHPDoc --- functions.php | 152 ++++++++++++++++++++++++++++++++++++++++---------- 1 file changed, 124 insertions(+), 28 deletions(-) diff --git a/functions.php b/functions.php index 6a074de..105714e 100644 --- a/functions.php +++ b/functions.php @@ -1,11 +1,20 @@ Date: Wed, 7 Feb 2024 08:10:48 +0100 Subject: [PATCH 36/37] fox --- cleanup.php | 1 - 1 file changed, 1 deletion(-) diff --git a/cleanup.php b/cleanup.php index 49d6a0d..e584c6c 100644 --- a/cleanup.php +++ b/cleanup.php @@ -1,5 +1,4 @@ Date: Wed, 7 Feb 2024 08:11:16 +0100 Subject: [PATCH 37/37] fix --- prepare.php | 1 - report.php | 1 - test.php | 1 - 3 files changed, 3 deletions(-) diff --git a/prepare.php b/prepare.php index 53b6f03..7283923 100644 --- a/prepare.php +++ b/prepare.php @@ -1,5 +1,4 @@