WordPress.org

Make WordPress Core

Changeset 40239


Ignore:
Timestamp:
03/08/2017 12:00:47 AM (15 months ago)
Author:
johnbillion
Message:

Build/Test tools: In Travis, skip some tests when not on trunk.

This skips time sensitive tests (copyright year and PHP/MySQL version requirements) when tests are run on branches on Travis.

Props netweb, jorbin
Fixes #39486

Location:
trunk
Files:
5 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/wp-includes/pluggable.php

    r40183 r40239  
    901901    do_action( 'set_logged_in_cookie', $logged_in_cookie, $expire, $expiration, $user_id, 'logged_in' );
    902902
     903    /**
     904     * Allows preventing auth cookies from actually being sent to the client.
     905     *
     906     * @since 4.7.4
     907     *
     908     * @param bool $send Whether to send auth cookies to the client.
     909     */
     910    if ( ! apply_filters( 'send_auth_cookies', true ) ) {
     911        return;
     912    }
     913
    903914    setcookie($auth_cookie_name, $auth_cookie, $expire, PLUGINS_COOKIE_PATH, COOKIE_DOMAIN, $secure, true);
    904915    setcookie($auth_cookie_name, $auth_cookie, $expire, ADMIN_COOKIE_PATH, COOKIE_DOMAIN, $secure, true);
     
    922933     */
    923934    do_action( 'clear_auth_cookie' );
     935
     936    /**
     937     * Allows preventing auth cookies from actually being sent to the client.
     938     *
     939     * @since 4.7.4
     940     *
     941     * @param bool $send Whether to send auth cookies to the client.
     942     */
     943    if ( ! apply_filters( 'send_auth_cookies', true ) ) {
     944        return;
     945    }
    924946
    925947    setcookie( AUTH_COOKIE,        ' ', time() - YEAR_IN_SECONDS, ADMIN_COOKIE_PATH,   COOKIE_DOMAIN );
  • trunk/tests/phpunit/includes/functions.php

    r39219 r40239  
    165165// Skip `setcookie` calls in auth_cookie functions due to warning:
    166166// Cannot modify header information - headers already sent by ...
    167 
    168 function wp_set_auth_cookie( $user_id, $remember = false, $secure = '', $token = '' ) {
    169     $auth_cookie = null;
    170     $expire = null;
    171     $expiration = null;
    172     $user_id = null;
    173     $scheme = null;
    174     /** This action is documented in wp-inclues/pluggable.php */
    175     do_action( 'set_auth_cookie', $auth_cookie, $expire, $expiration, $user_id, $scheme );
    176     $logged_in_cookie = null;
    177     /** This action is documented in wp-inclues/pluggable.php */
    178     do_action( 'set_logged_in_cookie', $logged_in_cookie, $expire, $expiration, $user_id, 'logged_in' );
    179 }
    180 
    181 function wp_clear_auth_cookie() {
    182     /** This action is documented in wp-inclues/pluggable.php */
    183     do_action( 'clear_auth_cookie' );
    184 }
     167tests_add_filter( 'send_auth_cookies', '__return_false' );
  • trunk/tests/phpunit/includes/testcase.php

    r39919 r40239  
    175175        $_POST = array();
    176176        self::flush_cache();
     177    }
     178
     179    /**
     180     * Allow tests to be skipped on some automated runs
     181     *
     182     * For test runs on Travis for something other than trunk/master
     183     * we want to skip tests that only need to run for master.
     184     */
     185    public function skipOnAutomatedBranches() {
     186        // gentenv can be disabled
     187        if ( ! function_exists( 'getenv' ) ) {
     188            return false;
     189        }
     190
     191        // https://docs.travis-ci.com/user/environment-variables/#Default-Environment-Variables
     192        $travis_branch       = getenv( 'TRAVIS_BRANCH' );
     193        $travis_pull_request = getenv( 'TRAVIS_PULL_REQUEST' );
     194
     195        if ( false !== $travis_pull_request && 'master' !== $travis_branch ) {
     196            $this->markTestSkipped( 'For automated test runs, this test is only run on trunk/master' );
     197        }
    177198    }
    178199
  • trunk/tests/phpunit/tests/basic.php

    r39478 r40239  
    99
    1010    function test_license() {
     11        // This test is designed to only run on trunk/master
     12        $this->skipOnAutomatedBranches();
     13
    1114        $license = file_get_contents( ABSPATH . 'license.txt' );
    1215        preg_match( '#Copyright 2011-(\d+) by the contributors#', $license, $matches );
  • trunk/tests/phpunit/tests/external-http/basic.php

    r39583 r40239  
    66
    77    function test_readme() {
     8        // This test is designed to only run on trunk/master
     9        $this->skipOnAutomatedBranches();
     10
    811        $readme = file_get_contents( ABSPATH . 'readme.html' );
    912
Note: See TracChangeset for help on using the changeset viewer.