From a927a48b3156f81f73937ad7fc0a66efa0a06934 Mon Sep 17 00:00:00 2001 From: Dominik Schilling Date: Fri, 8 Jul 2016 18:16:07 +0000 Subject: [PATCH] Unit tests: Don't change the `memory_limit` setting during tests. 40M isn't enough and can lead to an "out of memory" error. Change `test_wp_raise_memory_limit()` to test that `wp_raise_memory_limit()` doesn't *lower* the memory limit. See [38015]. See #32075. git-svn-id: https://develop.svn.wordpress.org/trunk@38016 602fd350-edb4-49c9-b593-d223f7449a82 --- tests/phpunit/tests/functions.php | 14 +++++++++++--- 1 file changed, 11 insertions(+), 3 deletions(-) diff --git a/tests/phpunit/tests/functions.php b/tests/phpunit/tests/functions.php index 12319d3aa4..13a0ff4726 100644 --- a/tests/phpunit/tests/functions.php +++ b/tests/phpunit/tests/functions.php @@ -875,8 +875,16 @@ class Tests_Functions extends WP_UnitTestCase { * @ticket 32075 */ function test_wp_raise_memory_limit() { - ini_set( 'memory_limit', '40M' ); - $this->assertSame( -1, wp_raise_memory_limit() ); - $this->assertEquals( '-1', ini_get( 'memory_limit' ) ); + if ( -1 !== WP_MAX_MEMORY_LIMIT ) { + $this->markTestSkipped( 'WP_MAX_MEMORY_LIMIT should be set to -1' ); + } + + $ini_limit_before = ini_get( 'memory_limit' ); + $raised_limit = wp_raise_memory_limit(); + $ini_limit_after = ini_get( 'memory_limit' ); + + $this->assertSame( $ini_limit_before, $ini_limit_after ); + $this->assertSame( false, $raised_limit ); + $this->assertEquals( WP_MAX_MEMORY_LIMIT, $ini_limit_after ); } }