Make WordPress Core

Changeset 38016


Ignore:
Timestamp:
07/08/2016 06:16:07 PM (9 years ago)
Author:
ocean90
Message:

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.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/tests/phpunit/tests/functions.php

    r38015 r38016  
    876876     */
    877877    function test_wp_raise_memory_limit() {
    878         ini_set( 'memory_limit', '40M' );
    879         $this->assertSame( -1, wp_raise_memory_limit() );
    880         $this->assertEquals( '-1', ini_get( 'memory_limit' ) );
     878        if ( -1 !== WP_MAX_MEMORY_LIMIT ) {
     879            $this->markTestSkipped( 'WP_MAX_MEMORY_LIMIT should be set to -1' );
     880        }
     881
     882        $ini_limit_before = ini_get( 'memory_limit' );
     883        $raised_limit = wp_raise_memory_limit();
     884        $ini_limit_after = ini_get( 'memory_limit' );
     885
     886        $this->assertSame( $ini_limit_before, $ini_limit_after );
     887        $this->assertSame( false, $raised_limit );
     888        $this->assertEquals( WP_MAX_MEMORY_LIMIT, $ini_limit_after );
    881889    }
    882890}
Note: See TracChangeset for help on using the changeset viewer.