mirror of
https://github.com/Icinga/icingaweb2.git
synced 2026-05-21 17:41:44 -04:00
Add SPDX license headers and mark source files as GPL-3.0-or-later to preserve the option to relicense under later GPL versions.
45 lines
1.3 KiB
PHP
45 lines
1.3 KiB
PHP
<?php
|
|
|
|
// SPDX-FileCopyrightText: 2018 Icinga GmbH <https://icinga.com>
|
|
// SPDX-License-Identifier: GPL-3.0-or-later
|
|
|
|
namespace Tests\Icinga\Util;
|
|
|
|
use Icinga\Util\Environment;
|
|
use Icinga\Test\BaseTestCase;
|
|
|
|
class EnvironmentTest extends BaseTestCase
|
|
{
|
|
public function testRaiseMemoryLimit()
|
|
{
|
|
// set a low limit
|
|
ini_set('memory_limit', '128M');
|
|
|
|
Environment::raiseMemoryLimit('512M');
|
|
$this->assertEquals('536870912' /* 512M */, ini_get('memory_limit'));
|
|
|
|
Environment::raiseMemoryLimit('1G');
|
|
$this->assertEquals('1073741824' /* 1G */, ini_get('memory_limit'));
|
|
|
|
Environment::raiseMemoryLimit('512M');
|
|
$this->assertEquals('1073741824' /* 1G */, ini_get('memory_limit'));
|
|
|
|
// in phpunit usually there is no limit
|
|
ini_set('memory_limit', '-1');
|
|
}
|
|
|
|
public function testRaiseExecutionTime()
|
|
{
|
|
Environment::raiseExecutionTime(300);
|
|
$this->assertEquals(300, ini_get('max_execution_time'));
|
|
|
|
Environment::raiseExecutionTime(600);
|
|
$this->assertEquals(600, ini_get('max_execution_time'));
|
|
|
|
Environment::raiseExecutionTime(300);
|
|
$this->assertEquals(600, ini_get('max_execution_time'));
|
|
|
|
// in phpunit usually there is no limit
|
|
ini_set('max_execution_time', '0');
|
|
}
|
|
}
|