|
|
@@ -433,4 +433,41 @@ class ErrorHandlerTest extends TestCase
|
|
|
$errorHandler->handleException($error);
|
|
|
$this->assertContains('Unexpected variable foo', $errorHandler->response->body(), 'message missing.');
|
|
|
}
|
|
|
+
|
|
|
+ /**
|
|
|
+ * Data provider for memory limit changing.
|
|
|
+ *
|
|
|
+ * @return array
|
|
|
+ */
|
|
|
+ public function memoryLimitProvider()
|
|
|
+ {
|
|
|
+ return [
|
|
|
+ // start, adjust, expected
|
|
|
+ ['256M', 4, '262148K'],
|
|
|
+ ['262144K', 4, '262148K'],
|
|
|
+ ['1G', 128, '1048704K'],
|
|
|
+ ];
|
|
|
+ }
|
|
|
+
|
|
|
+ /**
|
|
|
+ * Test increasing the memory limit.
|
|
|
+ *
|
|
|
+ * @dataProvider memoryLimitProvider
|
|
|
+ * @return void
|
|
|
+ */
|
|
|
+ public function testIncreaseMemoryLimit($start, $adjust, $expected)
|
|
|
+ {
|
|
|
+ $initial = ini_get('memory_limit');
|
|
|
+ $this->skipIf(strlen($initial) === 0, 'Cannot read memory limit, and cannot test increasing it.');
|
|
|
+
|
|
|
+ // phpunit.xml often has -1 as memory limit
|
|
|
+ ini_set('memory_limit', $start);
|
|
|
+
|
|
|
+ $errorHandler = new TestErrorHandler();
|
|
|
+ $this->assertNull($errorHandler->increaseMemoryLimit($adjust));
|
|
|
+ $new = ini_get('memory_limit');
|
|
|
+ $this->assertEquals($expected, $new, 'memory limit did not get increased.');
|
|
|
+
|
|
|
+ ini_set('memory_limit', $initial);
|
|
|
+ }
|
|
|
}
|