Skip to content

Commit

Permalink
don't mock but ini_set memory limit in tests
Browse files Browse the repository at this point in the history
  • Loading branch information
m-vo committed Sep 17, 2021
1 parent a623be3 commit 1b9400a
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 5 deletions.
4 changes: 2 additions & 2 deletions manager-bundle/src/Command/ContaoSetupCommand.php
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ class ContaoSetupCommand extends Command
/**
* @param (\Closure(array<string>):Process)|null $createProcessHandler
*/
public function __construct(string $projectDir, string $webDir, \Closure $createProcessHandler = null, string $memoryLimit = null)
public function __construct(string $projectDir, string $webDir, \Closure $createProcessHandler = null)
{
$this->webDir = Path::makeRelative($webDir, $projectDir);
$this->phpPath = (new PhpExecutableFinder())->find();
Expand All @@ -64,7 +64,7 @@ public function __construct(string $projectDir, string $webDir, \Closure $create
return new Process($command);
};

$this->memoryLimit = $memoryLimit ?? ini_get('memory_limit');
$this->memoryLimit = ini_get('memory_limit');

parent::__construct();
}
Expand Down
7 changes: 4 additions & 3 deletions manager-bundle/tests/Command/ContaoSetupCommandTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -46,10 +46,11 @@ public function testExecutesCommands(array $options, array $flags, array $phpFla

$phpPath = (new PhpExecutableFinder())->find();

array_unshift($phpFlags, '-dmemory_limit=1G');

$this->assertStringContainsString('php', $phpPath);

ini_set('memory_limit', '1G');
array_unshift($phpFlags, '-dmemory_limit=1G');

$commandFilePath = (new \ReflectionClass(ContaoSetupCommand::class))->getFileName();
$consolePath = Path::join(Path::getDirectory($commandFilePath), '../../bin/contao-console');

Expand All @@ -65,7 +66,7 @@ public function testExecutesCommands(array $options, array $flags, array $phpFla

$createProcessHandler = $this->getCreateProcessHandler($processes, $commandArguments, $invocationCount);

$command = new ContaoSetupCommand('project/dir', 'project/dir/public', $createProcessHandler, '1G');
$command = new ContaoSetupCommand('project/dir', 'project/dir/public', $createProcessHandler);

(new CommandTester($command))->execute([], $options);

Expand Down

0 comments on commit 1b9400a

Please sign in to comment.