Skip to content

Commit

Permalink
fix: composer/install-highest (#124)
Browse files Browse the repository at this point in the history
* fix: composer/install-highest

* fix: composer/install-highest

* fix: composer/install-highest
  • Loading branch information
dkarlovi authored Mar 27, 2023
1 parent b0602e0 commit beb00e7
Show file tree
Hide file tree
Showing 7 changed files with 80 additions and 9 deletions.
26 changes: 23 additions & 3 deletions psalm.baseline.xml
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@
<file src="tests/functional/MakefileTestCase.php">
<LessSpecificReturnType>
<code>array</code>
<code>array</code>
</LessSpecificReturnType>
<MixedArgument>
<code>$command</code>
Expand Down Expand Up @@ -44,6 +43,10 @@
</file>
<file src="tests/functional/PHP/LibraryTest.php">
<MixedArgument>
<code>$composer</code>
<code>$composer</code>
<code>$mkdir</code>
<code>$mkdir</code>
<code>$mkdir</code>
<code>$mkdir</code>
<code>$mkdir</code>
Expand All @@ -55,11 +58,19 @@
<code><![CDATA[$this->paths()['shell: PHP']]]></code>
</MixedArgument>
<MixedAssignment>
<code>$composer</code>
<code>$composer</code>
<code>$mkdir</code>
<code>$mkdir</code>
<code>$mkdir</code>
<code>$test</code>
</MixedAssignment>
<PossiblyUndefinedStringArrayOffset>
<code><![CDATA[$this->paths()['analyze']]]></code>
<code><![CDATA[$this->paths()['composer: install-highest']]]></code>
<code><![CDATA[$this->paths()['composer: install-lowest']]]></code>
<code><![CDATA[$this->paths()['mkdir: phpqa']]]></code>
<code><![CDATA[$this->paths()['mkdir: phpqa']]]></code>
<code><![CDATA[$this->paths()['mkdir: phpqa']]]></code>
<code><![CDATA[$this->paths()['prepareAndAnalyze']]]></code>
<code><![CDATA[$this->paths()['shell: PHP']]]></code>
Expand All @@ -74,6 +85,8 @@
<file src="tests/functional/Pimcore/ApplicationTest.php">
<MixedArgument>
<code>$clean</code>
<code>$composer</code>
<code>$mkdir</code>
<code>$mkdir</code>
<code>$mkdir</code>
<code>$mkdir</code>
Expand All @@ -89,32 +102,39 @@
<code><![CDATA[$this->paths()['permissions: Pimcore']]]></code>
<code><![CDATA[$this->paths()['prepareAndAnalyze']]]></code>
<code><![CDATA[$this->paths()['shell: PHP']]]></code>
<code>$touch</code>
</MixedArgument>
<MixedAssignment>
<code>$clean</code>
<code>$composer</code>
<code>$mkdir</code>
<code>$mkdir</code>
<code>$testFunctional</code>
<code>$testUnit</code>
<code>$touch</code>
</MixedAssignment>
<PossiblyUndefinedStringArrayOffset>
<code><![CDATA[$this->paths()['analyze']]]></code>
<code><![CDATA[$this->paths()['build: dev']]]></code>
<code><![CDATA[$this->paths()['build: prod']]]></code>
<code><![CDATA[$this->paths()['clean: Pimcore application']]]></code>
<code><![CDATA[$this->paths()['composer: install']]]></code>
<code><![CDATA[$this->paths()['docker compose: start app dev']]]></code>
<code><![CDATA[$this->paths()['docker compose: start app prod']]]></code>
<code><![CDATA[$this->paths()['docker compose: start app test']]]></code>
<code><![CDATA[$this->paths()['docker compose: start app']]]></code>
<code><![CDATA[$this->paths()['docker compose: stop Pimcore app']]]></code>
<code><![CDATA[$this->paths()['mkdir: composer']]]></code>
<code><![CDATA[$this->paths()['mkdir: phpqa']]]></code>
<code><![CDATA[$this->paths()['mkdir: phpqa']]]></code>
<code><![CDATA[$this->paths()['permissions: Pimcore']]]></code>
<code><![CDATA[$this->paths()['prepareAndAnalyze']]]></code>
<code><![CDATA[$this->paths()['setup: Pimcore app test']]]></code>
<code><![CDATA[$this->paths()['shell: PHP']]]></code>
<code><![CDATA[$this->paths()['shell: app']]]></code>
<code><![CDATA[$this->paths()['test: functional app']]]></code>
<code><![CDATA[$this->paths()['test: unit']]]></code>
<code><![CDATA[$this->paths()['touch: composer.lock']]]></code>
</PossiblyUndefinedStringArrayOffset>
</file>
<file src="tests/functional/Pimcore/LibraryTest.php">
Expand All @@ -134,7 +154,7 @@
<code><![CDATA[$this->paths()['prepareAndAnalyze']]]></code>
<code><![CDATA[$this->paths()['setup: Pimcore library test']]]></code>
<code><![CDATA[$this->paths()['shell: PHP']]]></code>
<code><![CDATA[$this->paths()['touch']]]></code>
<code><![CDATA[$this->paths()['touch: .env']]]></code>
</MixedArgument>
<MixedAssignment>
<code>$mkdir</code>
Expand All @@ -154,7 +174,7 @@
<code><![CDATA[$this->paths()['shell: app library']]]></code>
<code><![CDATA[$this->paths()['test: functional library']]]></code>
<code><![CDATA[$this->paths()['test: unit']]]></code>
<code><![CDATA[$this->paths()['touch']]]></code>
<code><![CDATA[$this->paths()['touch: .env']]]></code>
</PossiblyUndefinedStringArrayOffset>
</file>
<file src="tests/functional/YASSG/CompatTest.php">
Expand Down
3 changes: 2 additions & 1 deletion resources/PHP/common.mk
Original file line number Diff line number Diff line change
Expand Up @@ -19,12 +19,13 @@ sh/php: | ${HOME}/.composer var/phpqa composer.lock ## Run PHP shell
${PHPQA_DOCKER_COMMAND} sh

composer/install: composer.lock
composer/install-highest: composer.lock
composer.lock: | ${HOME}/.composer var/phpqa
${PHPQA_DOCKER_COMMAND} composer install --audit
touch composer.lock
composer/install-lowest: ${HOME}/.composer var/phpqa
${PHPQA_DOCKER_COMMAND} composer upgrade --prefer-lowest
composer/install-highest: ${HOME}/.composer var/phpqa
${PHPQA_DOCKER_COMMAND} composer upgrade

composer/validate: | ${HOME}/.composer var/phpqa composer.lock
${PHPQA_DOCKER_COMMAND} composer validate --no-interaction
Expand Down
6 changes: 3 additions & 3 deletions tests/functional/MakefileTestCase.php
Original file line number Diff line number Diff line change
Expand Up @@ -178,7 +178,7 @@ public function generateHelpCommandsExecutionPathFixtures(): array
return $fixtures;
}

private function getMakefilePath(): string
protected function getMakefilePath(): string
{
$path = str_replace([__NAMESPACE__.'\\', '\\'], ['', \DIRECTORY_SEPARATOR], static::class);
$dir = pathinfo($path, \PATHINFO_DIRNAME);
Expand All @@ -191,7 +191,7 @@ private function getMakefilePath(): string
return sprintf('resources%2$s%1$s%2$s%3$s.mk', $dir, \DIRECTORY_SEPARATOR, mb_strtolower($name));
}

private function dryRun(
protected function dryRun(
string $makefile,
?string $makeCommand = null,
?array $args = null,
Expand All @@ -202,7 +202,7 @@ private function dryRun(
return array_filter(explode("\n", $this->execute($makefile, $makeCommand, $args, $directory)));
}

private function execute(
protected function execute(
string $makefile,
?string $makeCommand = null,
?array $args = null,
Expand Down
20 changes: 20 additions & 0 deletions tests/functional/PHP/LibraryTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,26 @@ final class LibraryTest extends MakefileTestCase
{
use PhpTrait;

public function testCanRunComposerInstallLowest(): void
{
$mkdir = $this->paths()['mkdir: phpqa'];
$composer = $this->paths()['composer: install-lowest'];
$expected = array_merge($mkdir, $composer);
$actual = $this->dryRun($this->getMakefilePath(), 'composer/install-lowest');

static::assertSame($expected, $actual);
}

public function testCanRunComposerInstallHighest(): void
{
$mkdir = $this->paths()['mkdir: phpqa'];
$composer = $this->paths()['composer: install-highest'];
$expected = array_merge($mkdir, $composer);
$actual = $this->dryRun($this->getMakefilePath(), 'composer/install-highest');

static::assertSame($expected, $actual);
}

protected function getExpectedInitPaths(): array
{
return [
Expand Down
15 changes: 14 additions & 1 deletion tests/functional/PHP/PhpTrait.php
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,16 @@ private function paths(): array
$this->generateDockerBuildxExecutionPath('prod'),
],

'composer: install' => [
$this->generatePhpqaExecutionPath('composer install --audit'),
],
'composer: install-lowest' => [
$this->generatePhpqaExecutionPath('composer upgrade --prefer-lowest'),
],
'composer: install-highest' => [
$this->generatePhpqaExecutionPath('composer upgrade'),
],

'docker compose: start app dev' => [
$this->generateDockerComposeAppExecutionPath('up --detach --remove-orphans --no-build', 'dev'),
],
Expand Down Expand Up @@ -115,9 +125,12 @@ private function paths(): array
'mkdir -p $HOME/.composer',
'mkdir -p var/phpqa',
],
'touch' => [
'touch: .env' => [
'touch .env',
],
'touch: composer.lock' => [
'touch composer.lock',
],
'clean: Pimcore application' => [
'rm -rf var/admin/* var/cache/* var/log/* var/tmp/*',
],
Expand Down
17 changes: 17 additions & 0 deletions tests/functional/Pimcore/ApplicationTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,23 @@ final class ApplicationTest extends MakefileTestCase
{
use PhpTrait;

public function testCanRunComposerInstall(): void
{
$filesystem = new Filesystem();
$filesystem->rename('composer.lock', 'composer.lock.old');

$mkdir = $this->paths()['mkdir: phpqa'];
$composer = $this->paths()['composer: install'];
$touch = $this->paths()['touch: composer.lock'];
$expected = array_merge($mkdir, $composer, $touch);

$actual = $this->dryRun($this->getMakefilePath(), 'composer/install');

$filesystem->rename('composer.lock.old', 'composer.lock');

static::assertSame($expected, $actual);
}

protected function setUp(): void
{
$filesystem = new Filesystem();
Expand Down
2 changes: 1 addition & 1 deletion tests/functional/Pimcore/LibraryTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ protected function getExpectedHelpCommandsExecutionPath(): array
'analyze' => array_merge($mkdir, $this->paths()['analyze']),
'clean' => $this->paths()['clean: library'],
'dist' => array_merge($mkdir, $this->paths()['prepareAndAnalyze'], $testUnit, $testFunctional),
'setup/test' => array_merge($this->paths()['docker compose: start library test'], $this->paths()['touch'], $this->paths()['setup: Pimcore library test']),
'setup/test' => array_merge($this->paths()['docker compose: start library test'], $this->paths()['touch: .env'], $this->paths()['setup: Pimcore library test']),
'sh/app' => $this->paths()['shell: app library'],
'sh/php' => array_merge($mkdir, $this->paths()['shell: PHP']),
'start/test' => $this->paths()['docker compose: start library test'],
Expand Down

0 comments on commit beb00e7

Please sign in to comment.