diff --git a/tests/HTTP/ClientTest.php b/tests/HTTP/ClientTest.php index 649702b..b014b62 100644 --- a/tests/HTTP/ClientTest.php +++ b/tests/HTTP/ClientTest.php @@ -209,12 +209,24 @@ public function testSendToGetLargeContent() $this->markTestSkipped('Set an environment value BASEURL to continue'); } + // Allow the peak memory usage limit to be specified externally, if needed. + // When running this test in different environments it may be appropriate to set a different limit. + $maxPeakMemoryUsageEnvVariable = 'SABRE_HTTP_TEST_GET_LARGE_CONTENT_MAX_PEAK_MEMORY_USAGE'; + $maxPeakMemoryUsage = \getenv($maxPeakMemoryUsageEnvVariable); + if (false === $maxPeakMemoryUsage) { + $maxPeakMemoryUsage = 60 * pow(1024, 2); + } + $request = new Request('GET', $url); $client = new Client(); $response = $client->send($request); $this->assertEquals(200, $response->getStatus()); - $this->assertLessThan(60 * pow(1024, 2), memory_get_peak_usage()); + $this->assertLessThan( + (int) $maxPeakMemoryUsage, + memory_get_peak_usage(), + "Hint: you can adjust the max peak memory usage allowed for this test by defining env variable $maxPeakMemoryUsageEnvVariable to be the desired max bytes" + ); } /**