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 git-svn-id: https://develop.svn.wordpress.org/trunk@40239 602fd350-edb4-49c9-b593-d223f7449a82
This commit is contained in:
parent
8bbe6a0d50
commit
868eba6850
@ -900,6 +900,17 @@ function wp_set_auth_cookie( $user_id, $remember = false, $secure = '', $token =
|
|||||||
*/
|
*/
|
||||||
do_action( 'set_logged_in_cookie', $logged_in_cookie, $expire, $expiration, $user_id, 'logged_in' );
|
do_action( 'set_logged_in_cookie', $logged_in_cookie, $expire, $expiration, $user_id, 'logged_in' );
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Allows preventing auth cookies from actually being sent to the client.
|
||||||
|
*
|
||||||
|
* @since 4.7.4
|
||||||
|
*
|
||||||
|
* @param bool $send Whether to send auth cookies to the client.
|
||||||
|
*/
|
||||||
|
if ( ! apply_filters( 'send_auth_cookies', true ) ) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
setcookie($auth_cookie_name, $auth_cookie, $expire, PLUGINS_COOKIE_PATH, COOKIE_DOMAIN, $secure, true);
|
setcookie($auth_cookie_name, $auth_cookie, $expire, PLUGINS_COOKIE_PATH, COOKIE_DOMAIN, $secure, true);
|
||||||
setcookie($auth_cookie_name, $auth_cookie, $expire, ADMIN_COOKIE_PATH, COOKIE_DOMAIN, $secure, true);
|
setcookie($auth_cookie_name, $auth_cookie, $expire, ADMIN_COOKIE_PATH, COOKIE_DOMAIN, $secure, true);
|
||||||
setcookie(LOGGED_IN_COOKIE, $logged_in_cookie, $expire, COOKIEPATH, COOKIE_DOMAIN, $secure_logged_in_cookie, true);
|
setcookie(LOGGED_IN_COOKIE, $logged_in_cookie, $expire, COOKIEPATH, COOKIE_DOMAIN, $secure_logged_in_cookie, true);
|
||||||
@ -922,6 +933,17 @@ function wp_clear_auth_cookie() {
|
|||||||
*/
|
*/
|
||||||
do_action( 'clear_auth_cookie' );
|
do_action( 'clear_auth_cookie' );
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Allows preventing auth cookies from actually being sent to the client.
|
||||||
|
*
|
||||||
|
* @since 4.7.4
|
||||||
|
*
|
||||||
|
* @param bool $send Whether to send auth cookies to the client.
|
||||||
|
*/
|
||||||
|
if ( ! apply_filters( 'send_auth_cookies', true ) ) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
setcookie( AUTH_COOKIE, ' ', time() - YEAR_IN_SECONDS, ADMIN_COOKIE_PATH, COOKIE_DOMAIN );
|
setcookie( AUTH_COOKIE, ' ', time() - YEAR_IN_SECONDS, ADMIN_COOKIE_PATH, COOKIE_DOMAIN );
|
||||||
setcookie( SECURE_AUTH_COOKIE, ' ', time() - YEAR_IN_SECONDS, ADMIN_COOKIE_PATH, COOKIE_DOMAIN );
|
setcookie( SECURE_AUTH_COOKIE, ' ', time() - YEAR_IN_SECONDS, ADMIN_COOKIE_PATH, COOKIE_DOMAIN );
|
||||||
setcookie( AUTH_COOKIE, ' ', time() - YEAR_IN_SECONDS, PLUGINS_COOKIE_PATH, COOKIE_DOMAIN );
|
setcookie( AUTH_COOKIE, ' ', time() - YEAR_IN_SECONDS, PLUGINS_COOKIE_PATH, COOKIE_DOMAIN );
|
||||||
|
@ -164,21 +164,4 @@ function _upload_dir_https( $uploads ) {
|
|||||||
|
|
||||||
// Skip `setcookie` calls in auth_cookie functions due to warning:
|
// Skip `setcookie` calls in auth_cookie functions due to warning:
|
||||||
// Cannot modify header information - headers already sent by ...
|
// Cannot modify header information - headers already sent by ...
|
||||||
|
tests_add_filter( 'send_auth_cookies', '__return_false' );
|
||||||
function wp_set_auth_cookie( $user_id, $remember = false, $secure = '', $token = '' ) {
|
|
||||||
$auth_cookie = null;
|
|
||||||
$expire = null;
|
|
||||||
$expiration = null;
|
|
||||||
$user_id = null;
|
|
||||||
$scheme = null;
|
|
||||||
/** This action is documented in wp-inclues/pluggable.php */
|
|
||||||
do_action( 'set_auth_cookie', $auth_cookie, $expire, $expiration, $user_id, $scheme );
|
|
||||||
$logged_in_cookie = null;
|
|
||||||
/** This action is documented in wp-inclues/pluggable.php */
|
|
||||||
do_action( 'set_logged_in_cookie', $logged_in_cookie, $expire, $expiration, $user_id, 'logged_in' );
|
|
||||||
}
|
|
||||||
|
|
||||||
function wp_clear_auth_cookie() {
|
|
||||||
/** This action is documented in wp-inclues/pluggable.php */
|
|
||||||
do_action( 'clear_auth_cookie' );
|
|
||||||
}
|
|
||||||
|
@ -176,6 +176,27 @@ class WP_UnitTestCase extends PHPUnit_Framework_TestCase {
|
|||||||
self::flush_cache();
|
self::flush_cache();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Allow tests to be skipped on some automated runs
|
||||||
|
*
|
||||||
|
* For test runs on Travis for something other than trunk/master
|
||||||
|
* 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 ) {
|
||||||
|
$this->markTestSkipped( 'For automated test runs, this test is only run on trunk/master' );
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Unregister existing post types and register defaults.
|
* Unregister existing post types and register defaults.
|
||||||
*
|
*
|
||||||
|
@ -8,6 +8,9 @@
|
|||||||
class Tests_Basic extends WP_UnitTestCase {
|
class Tests_Basic extends WP_UnitTestCase {
|
||||||
|
|
||||||
function test_license() {
|
function test_license() {
|
||||||
|
// This test is designed to only run on trunk/master
|
||||||
|
$this->skipOnAutomatedBranches();
|
||||||
|
|
||||||
$license = file_get_contents( ABSPATH . 'license.txt' );
|
$license = file_get_contents( ABSPATH . 'license.txt' );
|
||||||
preg_match( '#Copyright 2011-(\d+) by the contributors#', $license, $matches );
|
preg_match( '#Copyright 2011-(\d+) by the contributors#', $license, $matches );
|
||||||
$this_year = date( 'Y' );
|
$this_year = date( 'Y' );
|
||||||
|
@ -5,6 +5,9 @@
|
|||||||
class Tests_External_HTTP_Basic extends WP_UnitTestCase {
|
class Tests_External_HTTP_Basic extends WP_UnitTestCase {
|
||||||
|
|
||||||
function test_readme() {
|
function test_readme() {
|
||||||
|
// This test is designed to only run on trunk/master
|
||||||
|
$this->skipOnAutomatedBranches();
|
||||||
|
|
||||||
$readme = file_get_contents( ABSPATH . 'readme.html' );
|
$readme = file_get_contents( ABSPATH . 'readme.html' );
|
||||||
|
|
||||||
preg_match( '#Recommendations.*PHP</a> version <strong>([0-9.]*)#s', $readme, $matches );
|
preg_match( '#Recommendations.*PHP</a> version <strong>([0-9.]*)#s', $readme, $matches );
|
||||||
|
Loading…
Reference in New Issue
Block a user