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
This commit is contained in:
Dominik Schilling 2016-07-08 18:16:07 +00:00
parent c68f1ec772
commit a927a48b31
1 changed files with 11 additions and 3 deletions

View File

@ -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 );
}
}