1 bootstrap.test BootstrapOverrideServerVariablesTestCase::testCheckMemoryLimit()

Tests that the backdrop_check_memory_limit() function works as expected.

File

core/modules/simpletest/tests/bootstrap.test, line 670

Class

BootstrapOverrideServerVariablesTestCase
Tests for overriding server variables via the API.

Code

function testCheckMemoryLimit() {
  // Test that a very reasonable amount of memory is available.
  $this->assertTrue(backdrop_check_memory_limit('30MB'), '30MB of memory tested available.');

  // Test an unlimited memory limit.
  // The function should always return true if the memory limit is set to -1.
  $this->assertTrue(backdrop_check_memory_limit('9999999999YB', -1), 'backdrop_check_memory_limit() returns TRUE when a limit of -1 (none) is supplied');

  // Test that even though we have 30MB of memory available - the function
  // returns FALSE when given an upper limit for how much memory can be used.
  $this->assertFalse(backdrop_check_memory_limit('30MB', '16MB'), 'backdrop_check_memory_limit() returns FALSE with a 16MB upper limit on a 30MB requirement.');

  // Test that an equal amount of memory to the amount requested returns TRUE.
  $this->assertTrue(backdrop_check_memory_limit('30MB', '30MB'), 'backdrop_check_memory_limit() returns TRUE when requesting 30MB on a 30MB requirement.');
}