Skip to content

Commit

Permalink
Merge pull request silverstripe#10151 from creative-commoners/pulls/4…
Browse files Browse the repository at this point in the history
…/tests-from-recipe

MNT Adjust a couple of unit tests to run from recipe-kitchen-sink
  • Loading branch information
michalkleiner authored Nov 16, 2021
2 parents 29fa365 + 081537d commit 96bc525
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 11 deletions.
21 changes: 11 additions & 10 deletions tests/php/Core/MemoryLimitTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -44,28 +44,29 @@ public function testIncreaseMemoryLimitTo()
{
// ini_set('memory_limit', '64M');
// current memory usage in travis is 197M, can't ini_set this down to 64M
// for recipe-kitchen-sink, it's 284M
// Using a higher memory limit instead
ini_set('memory_limit', '230M');
Environment::setMemoryLimitMax('256M');
ini_set('memory_limit', '330M');
Environment::setMemoryLimitMax('512M');

// It can go up
Environment::increaseMemoryLimitTo('240M');
$this->assertEquals('240M', ini_get('memory_limit'));
Environment::increaseMemoryLimitTo('340M');
$this->assertEquals('340M', ini_get('memory_limit'));

// But not down
Environment::increaseMemoryLimitTo('220M');
$this->assertEquals('240M', ini_get('memory_limit'));
Environment::increaseMemoryLimitTo('320M');
$this->assertEquals('340M', ini_get('memory_limit'));

// Test the different kinds of syntaxes
Environment::increaseMemoryLimitTo(1024*1024*250);
$this->assertEquals('250M', ini_get('memory_limit'));
Environment::increaseMemoryLimitTo(1024*1024*350);
$this->assertEquals('350M', ini_get('memory_limit'));

Environment::increaseMemoryLimitTo('109600K');
$this->assertEquals('250M', ini_get('memory_limit'));
$this->assertEquals('350M', ini_get('memory_limit'));

// Attempting to increase past max size only sets to max
Environment::increaseMemoryLimitTo('1G');
$this->assertEquals('256M', ini_get('memory_limit'));
$this->assertEquals('512M', ini_get('memory_limit'));

// No argument means unlimited (but only if originally allowed)
if (is_numeric($this->origMemLimitMax) && $this->origMemLimitMax < 0) {
Expand Down
2 changes: 1 addition & 1 deletion tests/php/Logging/DetailedErrorFormatterTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ public function testFormatWithException()
$this->assertStringContainsString("Line 32 in $base/DetailedErrorFormatterTest/ErrorGenerator.php", $output);
$this->assertStringContainsString('* 32: throw new Exception(\'Error\');', $output);
$this->assertStringContainsString(
'SilverStripe\\Logging\\Tests\\DetailedErrorFormatterTest\\ErrorGenerator->mockException(4)',
'SilverStripe\\Logging\\Tests\\DetailedErrorFormatterTest\\ErrorGenerator->mockException',
$output
);
}
Expand Down

0 comments on commit 96bc525

Please sign in to comment.