WordPress.org

Make WordPress Core

Changeset 47000


Ignore:
Timestamp:
12/20/2019 01:10:23 AM (2 years ago)
Author:
SergeyBiryukov
Message:

Tests: Correct the check for pull requests in WP_UnitTestCase_Base::skipOnAutomatedBranches().

Mark the test as failed if the environment variables are unavailable.

Fixes #49050.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/tests/phpunit/includes/abstract-testcase.php

    r46986 r47000  
    187187     */
    188188    public function skipOnAutomatedBranches() {
    189         // gentenv can be disabled
    190         if ( ! function_exists( 'getenv' ) ) {
    191             return false;
    192         }
    193 
    194189        // https://docs.travis-ci.com/user/environment-variables/#Default-Environment-Variables
    195190        $travis_branch       = getenv( 'TRAVIS_BRANCH' );
    196191        $travis_pull_request = getenv( 'TRAVIS_PULL_REQUEST' );
    197192
    198         if ( false !== $travis_pull_request && 'master' !== $travis_branch ) {
     193        if ( ! $travis_branch || ! $travis_pull_request ) {
     194            $this->fail( 'Could not read TRAVIS_BRANCH or TRAVIS_PULL_REQUEST' );
     195        }
     196
     197        if ( 'master' !== $travis_branch || 'false' !== $travis_pull_request ) {
    199198            $this->markTestSkipped( 'For automated test runs, this test is only run on trunk/master' );
    200199        }
Note: See TracChangeset for help on using the changeset viewer.