From f2f8f3f1ea7ccb7eeb9858b6c9101674c9e9e0a5 Mon Sep 17 00:00:00 2001 From: chinpei215 Date: Sun, 29 Nov 2015 22:30:33 +0900 Subject: [PATCH 1/2] Add test for #7224 --- lib/Cake/Test/Case/Core/AppTest.php | 32 +++++++++++++++++++++++++++++ 1 file changed, 32 insertions(+) diff --git a/lib/Cake/Test/Case/Core/AppTest.php b/lib/Cake/Test/Case/Core/AppTest.php index fec084ee3..da587dfef 100644 --- a/lib/Cake/Test/Case/Core/AppTest.php +++ b/lib/Cake/Test/Case/Core/AppTest.php @@ -829,4 +829,36 @@ class AppTest extends CakeTestCase { App::uses('TestPluginOtherLibrary', 'TestPlugin.Lib'); $this->assertTrue(class_exists('TestPluginOtherLibrary')); } + +/** + * Test that increaseMemoryLimit increases the maximum amount of memory actually + * + * @dataProvider memoryVariationProvider + * @return void + */ + public function testIncreaseMemoryLimit($memoryLimit, $additionalKb, $expected) { + $this->skipIf(!function_exists('ini_set')); + + $originalMemoryLimit = ini_get('memory_limit'); + + ini_set('memory_limit', $memoryLimit); + App::increaseMemoryLimit($additionalKb); + $this->assertEquals($expected, ini_get('memory_limit')); + + ini_set('memory_limit', $originalMemoryLimit); + } + +/** + * Data provider function for testIncreaseMemoryLimit + * + * @return + */ + public function memoryVariationProvider() { + return array( + array('131072K', 100000, '231072K'), + array('256M', 1, '262145K'), + array('1G', 1, '1048577K'), + array('-1', 100000, -1) + ); + } } From 415661b18a18804eabd47fe107f60150da1e5520 Mon Sep 17 00:00:00 2001 From: chinpei215 Date: Mon, 30 Nov 2015 00:00:01 +0900 Subject: [PATCH 2/2] Fix data type and docblock --- lib/Cake/Test/Case/Core/AppTest.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/lib/Cake/Test/Case/Core/AppTest.php b/lib/Cake/Test/Case/Core/AppTest.php index da587dfef..ecaa4bd92 100644 --- a/lib/Cake/Test/Case/Core/AppTest.php +++ b/lib/Cake/Test/Case/Core/AppTest.php @@ -851,14 +851,14 @@ class AppTest extends CakeTestCase { /** * Data provider function for testIncreaseMemoryLimit * - * @return + * @return void */ public function memoryVariationProvider() { return array( array('131072K', 100000, '231072K'), array('256M', 1, '262145K'), array('1G', 1, '1048577K'), - array('-1', 100000, -1) + array('-1', 100000, '-1') ); } }