diff options
author | David Rothstein <drothstein@gmail.com> | 2013-08-05 23:58:15 -0400 |
---|---|---|
committer | David Rothstein <drothstein@gmail.com> | 2013-08-05 23:58:15 -0400 |
commit | 19e65b966c79e7061827ef5f21ac67cd1159806c (patch) | |
tree | f5715889843ee7c991ff70083f31b2a55a0a2656 /modules/simpletest | |
parent | ebe236b0c03750c624cd00db96fc535077e6f890 (diff) | |
download | brdo-19e65b966c79e7061827ef5f21ac67cd1159806c.tar.gz brdo-19e65b966c79e7061827ef5f21ac67cd1159806c.tar.bz2 |
Issue #1453984 by xjm, naxoc, Dave Reid, underq, dags, tim.plunkett, Heine: Fixed Color module doesn't test for unlimited memory.
Diffstat (limited to 'modules/simpletest')
-rw-r--r-- | modules/simpletest/simpletest.install | 2 | ||||
-rw-r--r-- | modules/simpletest/tests/bootstrap.test | 24 |
2 files changed, 24 insertions, 2 deletions
diff --git a/modules/simpletest/simpletest.install b/modules/simpletest/simpletest.install index ea847f4ea..6c6f5694d 100644 --- a/modules/simpletest/simpletest.install +++ b/modules/simpletest/simpletest.install @@ -63,7 +63,7 @@ function simpletest_requirements($phase) { // Check the current memory limit. If it is set too low, SimpleTest will fail // to load all tests and throw a fatal error. $memory_limit = ini_get('memory_limit'); - if ($memory_limit && $memory_limit != -1 && parse_size($memory_limit) < parse_size(SIMPLETEST_MINIMUM_PHP_MEMORY_LIMIT)) { + if (!drupal_check_memory_limit(SIMPLETEST_MINIMUM_PHP_MEMORY_LIMIT, $memory_limit)) { $requirements['php_memory_limit']['severity'] = REQUIREMENT_ERROR; $requirements['php_memory_limit']['description'] = $t('The testing framework requires the PHP memory limit to be at least %memory_minimum_limit. The current value is %memory_limit. <a href="@url">Follow these steps to continue</a>.', array('%memory_limit' => $memory_limit, '%memory_minimum_limit' => SIMPLETEST_MINIMUM_PHP_MEMORY_LIMIT, '@url' => 'http://drupal.org/node/207036')); } diff --git a/modules/simpletest/tests/bootstrap.test b/modules/simpletest/tests/bootstrap.test index 84c0551cc..87b59608e 100644 --- a/modules/simpletest/tests/bootstrap.test +++ b/modules/simpletest/tests/bootstrap.test @@ -459,6 +459,29 @@ class BootstrapMiscTestCase extends DrupalUnitTestCase { $expected = array('fragment' => 'y', 'attributes' => array('title' => 'Y', 'class' => array('a', 'b', 'c', 'd')), 'language' => 'en', 'html' => TRUE); $this->assertIdentical(drupal_array_merge_deep($link_options_1, $link_options_2), $expected, 'drupal_array_merge_deep() returned a properly merged array.'); } + + /** + * Tests that the drupal_check_memory_limit() function works as expected. + */ + function testCheckMemoryLimit() { + $memory_limit = ini_get('memory_limit'); + // Test that a very reasonable amount of memory is available. + $this->assertTrue(drupal_check_memory_limit('30MB'), '30MB of memory tested available.'); + + // Get the available memory and multiply it by two to make it unreasonably + // high. + $twice_avail_memory = ($memory_limit * 2) . 'MB'; + + // The function should always return true if the memory limit is set to -1. + $this->assertTrue(drupal_check_memory_limit($twice_avail_memory, -1), 'drupal_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(drupal_check_memory_limit('30MB', '16MB'), 'drupal_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(drupal_check_memory_limit('30MB', '30MB'), 'drupal_check_memory_limit() returns TRUE when requesting 30MB on a 30MB requirement.'); + } } /** @@ -506,4 +529,3 @@ class BootstrapOverrideServerVariablesTestCase extends DrupalUnitTestCase { } } } - |