Skip to content

Commit

Permalink
TASK: Catch OutofboundsException (#734)
Browse files Browse the repository at this point in the history
* TASK: Catch OutofboundsException

* Apply php-cs-fixer changes

---------

Co-authored-by: sabbelasichon <[email protected]>
  • Loading branch information
sabbelasichon and sabbelasichon authored Apr 4, 2023
1 parent c0c4b83 commit 5afca44
Show file tree
Hide file tree
Showing 4 changed files with 23 additions and 2 deletions.
6 changes: 5 additions & 1 deletion src/Domain/Version/ComposerVersionChecker.php
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,10 @@ final class ComposerVersionChecker implements VersionCheckerInterface
{
public function isSatisified(string $packageName, string $constraint): bool
{
return InstalledVersions::satisfies(new VersionParser(), $packageName, $constraint);
try {
return InstalledVersions::satisfies(new VersionParser(), $packageName, $constraint);
} catch (\OutOfBoundsException $outOfBoundsException) {
return false;
}
}
}
1 change: 1 addition & 0 deletions src/Task/TYPO3/CMS/AbstractCliTask.php
Original file line number Diff line number Diff line change
Expand Up @@ -124,6 +124,7 @@ protected function fileExists(string $pathAndFileName, Node $node, CMS $applicat
{
$this->determineWorkingDirectoryAndTargetNode($node, $application, $deployment, $options);
$pathAndFileName = $this->workingDirectory . '/' . $pathAndFileName;

return $this->shell->executeOrSimulate('test -f ' . escapeshellarg($pathAndFileName), $this->targetNode, $deployment, true) !== false;
}
}
3 changes: 2 additions & 1 deletion src/Task/TYPO3/CMS/SetUpExtensionsTask.php
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ public function execute(Node $node, Application $application, Deployment $deploy

$commandArguments = [$scriptFileName];

if ($this->versionChecker->isSatisified('helhum/typo3-console', '>= 7.0.0')) {
if (version_compare($options['scriptFileVersion'], '7.0.0') >= 0 || $this->versionChecker->isSatisified('helhum/typo3-console', '>= 7.0.0')) {
$commandArguments[] = 'extension:setup';
if (!empty($options['extensionKeys'])) {
foreach ($options['extensionKeys'] as $extensionKey) {
Expand All @@ -77,6 +77,7 @@ public function execute(Node $node, Application $application, Deployment $deploy

protected function resolveOptions(OptionsResolver $resolver): void
{
$resolver->setDefault('scriptFileVersion', '0.0.0');
$resolver->setDefault('extensionKeys', []);
$resolver->setAllowedTypes('extensionKeys', 'array');
}
Expand Down
15 changes: 15 additions & 0 deletions tests/Unit/Task/TYPO3/CMS/SetUpExtensionsTaskTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -118,6 +118,21 @@ public function consoleIsFoundInCorrectPathWithoutAppDirectoryInVersionEqualOrHi
$this->assertCommandExecuted("php 'vendor/bin/typo3cms' 'extension:setup' '-e' 'foo' '-e' 'bar'");
}

/**
* @test
*/
public function consoleIsFoundInCorrectPathWithoutAppDirectoryDefinedWithVersionHigherOrEqualSeven(): void
{
$options = [
'scriptFileName' => 'vendor/bin/typo3cms',
'extensionKeys' => ['foo', 'bar'],
'scriptFileVersion' => '7.0.0'
];
$this->task->execute($this->node, $this->application, $this->deployment, $options);
$this->assertCommandExecuted("cd '{$this->deployment->getApplicationReleasePath($this->node)}'");
$this->assertCommandExecuted("php 'vendor/bin/typo3cms' 'extension:setup' '-e' 'foo' '-e' 'bar'");
}

/**
* @test
*/
Expand Down

0 comments on commit 5afca44

Please sign in to comment.