Tests: Don't preserve the global state for Ajax tests when using an external object cache.

Most of the Ajax tests are running in a separate PHP process, and thus PHPUnit attempts to preserve the global state from the parent process by serializing all globals. But this doesn't work for external object caches so we have to disable this "feature".

See #31491.

git-svn-id: https://develop.svn.wordpress.org/trunk@35209 602fd350-edb4-49c9-b593-d223f7449a82
This commit is contained in:
Dominik Schilling (ocean90) 2015-10-15 20:34:08 +00:00
parent a0305d5020
commit 666d07352e
2 changed files with 16 additions and 1 deletions

View File

@ -50,6 +50,21 @@ abstract class WP_Ajax_UnitTestCase extends WP_UnitTestCase {
'wp-remove-post-lock', 'dismiss-wp-pointer', 'heartbeat', 'nopriv_heartbeat',
);
/**
* Don't preserve the global state when using an external object cache.
*
* Most of the Ajax tests are running in a separate PHP process, and thus PHPUnit attempts
* to preserve the global state from the parent process by serializing all globals.
* But this doesn't work for external object caches so we have to disable this "feature".
*/
public function run( PHPUnit_Framework_TestResult $result = NULL ) {
if ( wp_using_ext_object_cache() ) {
$this->setPreserveGlobalState( false );
}
return parent::run( $result );
}
/**
* Set up the test fixture.
* Override wp_die(), pretend to be ajax, and suppres E_WARNINGs

View File

@ -6,6 +6,7 @@
* @subpackage UnitTests
* @since 3.5.0
* @group ajax
* @runInSeparateProcess
*/
class Tests_Ajax_Response extends WP_UnitTestCase {
@ -64,7 +65,6 @@ class Tests_Ajax_Response extends WP_UnitTestCase {
* Needs a separate process to get around the headers/output from the
* bootstrapper
* @ticket 19448
* @runInSeparateProcess
*/
public function test_response_charset_in_header() {