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. git-svn-id: https://develop.svn.wordpress.org/trunk@47000 602fd350-edb4-49c9-b593-d223f7449a82
This commit is contained in:
parent
2915793376
commit
d697471bb1
@ -186,16 +186,15 @@ abstract class WP_UnitTestCase_Base extends PHPUnit_Framework_TestCase {
|
||||
* we want to skip tests that only need to run for master.
|
||||
*/
|
||||
public function skipOnAutomatedBranches() {
|
||||
// gentenv can be disabled
|
||||
if ( ! function_exists( 'getenv' ) ) {
|
||||
return false;
|
||||
}
|
||||
|
||||
// https://docs.travis-ci.com/user/environment-variables/#Default-Environment-Variables
|
||||
$travis_branch = getenv( 'TRAVIS_BRANCH' );
|
||||
$travis_pull_request = getenv( 'TRAVIS_PULL_REQUEST' );
|
||||
|
||||
if ( false !== $travis_pull_request && 'master' !== $travis_branch ) {
|
||||
if ( ! $travis_branch || ! $travis_pull_request ) {
|
||||
$this->fail( 'Could not read TRAVIS_BRANCH or TRAVIS_PULL_REQUEST' );
|
||||
}
|
||||
|
||||
if ( 'master' !== $travis_branch || 'false' !== $travis_pull_request ) {
|
||||
$this->markTestSkipped( 'For automated test runs, this test is only run on trunk/master' );
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user