Skip to content

Commit

Permalink
fix: make init now dry run friendly (#110)
Browse files Browse the repository at this point in the history
* fix: make init now dry run friendly

* tests: make init tests
  • Loading branch information
dkarlovi authored Jan 31, 2023
1 parent aa0a49c commit 49b28f7
Show file tree
Hide file tree
Showing 7 changed files with 65 additions and 1 deletion.
3 changes: 2 additions & 1 deletion resources/Common/default.mk
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,8 @@ else
endif

define dir_copy
$(shell if [ -d "${1}" ]; then cp -a ${1}/. .; fi)
if [ -d "${1}" ]; then cp -a ${1}/. .; fi

endef

define str_reverse
Expand Down
8 changes: 8 additions & 0 deletions tests/functional/Common/DefaultTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,14 @@
*/
final class DefaultTest extends MakefileTestCase
{
protected function getExpectedInitPaths(): array
{
return [
'Common/Platform/$PLATFORM/default',
'Common/default',
];
}

protected function getExpectedHelpCommandsExecutionPath(): array
{
return [
Expand Down
10 changes: 10 additions & 0 deletions tests/functional/MakefileTestCase.php
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,8 @@ abstract class MakefileTestCase extends TestCase

abstract protected function getExpectedHelpCommandsExecutionPath(): array;

abstract protected function getExpectedInitPaths(): array;

protected function getExpectedHelp(): string
{
return $this->generateHelpList(array_keys($this->getExpectedHelpCommandsExecutionPath()));
Expand Down Expand Up @@ -86,6 +88,14 @@ public function testHelpIsTheDefaultCommand(): void
static::assertSame($expected, $actual);
}

public function testMakefileHasInit(): void
{
$expected = array_map(static fn (string $path): string => sprintf('if [ -d "$ROOT/resources/%1$s" ]; then cp -a $ROOT/resources/%1$s/. .; fi', $path), $this->getExpectedInitPaths());
$actual = $this->dryRun($this->getMakefilePath(), 'init');

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

/**
* @dataProvider generateHelpCommandsExecutionPathFixtures
*/
Expand Down
10 changes: 10 additions & 0 deletions tests/functional/PHP/LibraryTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,16 @@ final class LibraryTest extends MakefileTestCase
{
use PhpTrait;

protected function getExpectedInitPaths(): array
{
return [
'Common/Platform/$PLATFORM/default',
'Common/default',
'PHP/common',
'PHP/library',
];
}

protected function getExpectedHelpCommandsExecutionPath(): array
{
$mkdir = $this->paths()['mkdir: phpqa'];
Expand Down
11 changes: 11 additions & 0 deletions tests/functional/Pimcore/ApplicationTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,17 @@ protected function tearDown(): void
]);
}

protected function getExpectedInitPaths(): array
{
return [
'Common/Platform/$PLATFORM/default',
'Common/default',
'PHP/common',
'Pimcore/common',
'Pimcore/application',
];
}

protected function getExpectedHelpCommandsExecutionPath(): array
{
$mkdir = $this->paths()['mkdir: phpqa'];
Expand Down
11 changes: 11 additions & 0 deletions tests/functional/Pimcore/LibraryTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,17 @@ final class LibraryTest extends MakefileTestCase
{
use PhpTrait;

protected function getExpectedInitPaths(): array
{
return [
'Common/Platform/$PLATFORM/default',
'Common/default',
'PHP/common',
'Pimcore/common',
'Pimcore/library',
];
}

protected function getExpectedHelpCommandsExecutionPath(): array
{
$mkdir = $this->paths()['mkdir: phpqa'];
Expand Down
13 changes: 13 additions & 0 deletions tests/functional/YASSG/CompatTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,19 @@ final class CompatTest extends MakefileTestCase
'start' => 'Start app in APP_ENV mode (defaults to "dev")',
];

protected function getExpectedInitPaths(): array
{
return [
'Common/Platform/$PLATFORM/default',
'Common/default',
'PHP/common',
'Lighthouse/common',
'Visual/common',
'YASSG/common',
'YASSG/compat',
];
}

protected function getExpectedHelpCommandsExecutionPath(): array
{
$mkdir = $this->paths()['mkdir: phpqa'];
Expand Down

0 comments on commit 49b28f7

Please sign in to comment.