diff --git a/docker-compose.yml b/docker-compose.yml index 3d0ff62cd5..eddc4a5670 100644 --- a/docker-compose.yml +++ b/docker-compose.yml @@ -110,6 +110,8 @@ services: PHP_FPM_GID: ${PHP_FPM_GID-1000} TRAVIS_BRANCH: ${TRAVIS_BRANCH-false} TRAVIS_PULL_REQUEST: ${TRAVIS_PULL_REQUEST-false} + GITHUB_REF: ${GITHUB_REF-false} + GITHUB_EVENT_NAME: ${GITHUB_EVENT_NAME-false} volumes: - ./tools/local-env/phpunit-config.ini:/usr/local/etc/php/conf.d/phpunit-config.ini diff --git a/tests/phpunit/includes/abstract-testcase.php b/tests/phpunit/includes/abstract-testcase.php index bbc365f671..4bc966fdb7 100644 --- a/tests/phpunit/includes/abstract-testcase.php +++ b/tests/phpunit/includes/abstract-testcase.php @@ -193,14 +193,18 @@ abstract class WP_UnitTestCase_Base extends PHPUnit\Framework\TestCase { $github_event_name = getenv( 'GITHUB_EVENT_NAME' ); $github_ref = getenv( 'GITHUB_REF' ); - if ( ( ! $travis_branch || ! $travis_pull_request ) && ! $github_event_name ) { - return; - } + if ( 'false' !== $github_event_name ) { + // We're on GitHub Actions. + $skipped = array( 'pull_request', 'pull_request_target' ); - if ( ( 'master' !== $travis_branch || 'false' !== $travis_pull_request ) && empty( $github_event_name ) ) { - $this->markTestSkipped( 'For automated test runs, this test is only run on trunk/master' ); - } elseif ( in_array( $github_event_name, array( 'pull_request', 'pull_request_target' ), true ) || 'refs/heads/master' !== $github_ref ) { - $this->markTestSkipped( 'For automated test runs, this test is only run on trunk/master' ); + if ( in_array( $github_event_name, $skipped, true ) || 'refs/heads/master' !== $github_ref ) { + $this->markTestSkipped( 'For automated test runs, this test is only run on trunk/master - GitHub only' ); + } + } elseif ( 'false' !== $travis_branch ) { + // We're on Travis CI. + if ( 'master' !== $travis_branch || 'false' !== $travis_pull_request ) { + $this->markTestSkipped( 'For automated test runs, this test is only run on trunk/master - Travis only' ); + } } }