Skip to content

Commit

Permalink
Merge pull request #286 from infinum/change-test-variable
Browse files Browse the repository at this point in the history
Change test variable
  • Loading branch information
dingo-d authored May 5, 2022
2 parents d06ef94 + 9c9593a commit f1ca5bf
Show file tree
Hide file tree
Showing 13 changed files with 23 additions and 23 deletions.
2 changes: 1 addition & 1 deletion phpunit.xml
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
</testsuite>
</testsuites>
<php>
<env name="TEST" value="true" force="true" />
<env name="ES_TEST" value="true" force="true" />
</php>
<coverage processUncoveredFiles="true">
<include>
Expand Down
2 changes: 1 addition & 1 deletion src/Blocks/AbstractBlocks.php
Original file line number Diff line number Diff line change
Expand Up @@ -396,7 +396,7 @@ private function getBlocksFolderPath(): string
{
$blocksPath = \dirname(__DIR__, 5) . self::PATH_BLOCKS_PARENT;

if (\getenv('TEST')) {
if (\getenv('ES_TEST')) {
$blocksPath = \dirname(__DIR__, 2) . self::PATH_BLOCKS_PARENT_TESTS;
}

Expand Down
2 changes: 1 addition & 1 deletion src/Blocks/AbstractBlocksCli.php
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ protected function blocksMove(array $assocArgs, string $outputDir, bool $isCompo
$path = "{$outputDir}/{$block}";
$sourcePath = "{$sourcePathFolder}{$block}";

if (!\getenv('TEST')) {
if (!\getenv('ES_TEST')) {
$destinationPath = $root . \DIRECTORY_SEPARATOR . $path;
} else {
$destinationPath = $this->getProjectRootPath(true) . '/cliOutput';
Expand Down
2 changes: 1 addition & 1 deletion src/Blocks/BlockVariationCli.php
Original file line number Diff line number Diff line change
Expand Up @@ -86,7 +86,7 @@ public function __invoke(array $args, array $assocArgs)
$sourcePathFolder = $rootNode . $ds . static::OUTPUT_DIR . $ds;
$sourcePath = "{$sourcePathFolder}{$name}";

if (!\getenv('TEST')) {
if (!\getenv('ES_TEST')) {
$destinationPath = $root . $ds . $path;
} else {
$destinationPath = $this->getProjectRootPath(true) . '/cliOutput';
Expand Down
2 changes: 1 addition & 1 deletion src/Blocks/BlockWrapperCli.php
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,7 @@ public function __invoke(array $args, array $assocArgs)
$sourcePathFolder = $rootNode . $ds . static::OUTPUT_DIR . $ds;
$sourcePath = "{$sourcePathFolder}";

if (!\getenv('TEST')) {
if (!\getenv('ES_TEST')) {
$destinationPath = $root . $ds . $path;
} else {
$destinationPath = $this->getProjectRootPath(true) . '/cliOutput';
Expand Down
12 changes: 6 additions & 6 deletions src/Cli/AbstractCli.php
Original file line number Diff line number Diff line change
Expand Up @@ -345,7 +345,7 @@ public function outputWrite(string $outputDir, string $outputFile, array $args =
*/
public function getOutputDir(string $path = ''): string
{
if (\function_exists('\add_action') && !\getenv('TEST')) {
if (\function_exists('\add_action') && !\getenv('ES_TEST')) {
$root = $this->getProjectRootPath();
} else {
$root = $this->getProjectRootPath(true) . '/cliOutput';
Expand Down Expand Up @@ -396,7 +396,7 @@ public function renameNamespace(array $args = []): self
$namespace = $this->getNamespace($args);
$vendorPrefix = $this->getVendorPrefix($args);

if (\function_exists('\add_action') && !\getenv('TEST')) {
if (\function_exists('\add_action') && !\getenv('ES_TEST')) {
$output = \str_replace(
"namespace {$vendorPrefix}\EightshiftBoilerplate\\",
"namespace {$namespace}\\",
Expand Down Expand Up @@ -554,7 +554,7 @@ public function renameProjectName(array $args = []): self
{
$projectName = 'eightshift-boilerplate';

if (\function_exists('\add_action') && !\getenv('TEST')) {
if (\function_exists('\add_action') && !\getenv('ES_TEST')) {
$projectName = \basename(\dirname(__DIR__, 5));
}

Expand Down Expand Up @@ -796,7 +796,7 @@ public function getProjectRootPath(bool $isDev = false): string
{
$output = \dirname(__DIR__, 5);

if ($isDev || \getenv('TEST') !== false) {
if ($isDev || \getenv('ES_TEST') !== false) {
$output = \dirname(__DIR__, 2);
}

Expand All @@ -818,7 +818,7 @@ public function getProjectConfigRootPath(bool $isDev = false): string
$output = \dirname(__DIR__, 2);
}

if (\getenv('TEST')) {
if (\getenv('ES_TEST')) {
$output = \dirname(__DIR__, 2);
}

Expand Down Expand Up @@ -846,7 +846,7 @@ public function getFrontendLibsPath(string $path = ''): string
*/
public function getLibsPath(string $path = ''): string
{
if (\getenv('TEST')) {
if (\getenv('ES_TEST')) {
return "{$this->getProjectRootPath()}/{$path}";
}

Expand Down
2 changes: 1 addition & 1 deletion src/Cli/CliInitAll.php
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,7 @@ public function __invoke(array $args, array $assocArgs) // phpcs:ignore

WP_CLI::log('--------------------------------------------------');

if (!\getenv('TEST')) {
if (!\getenv('ES_TEST')) {
WP_CLI::log((string)shell_exec('npm run start')); // phpcs:ignore
}

Expand Down
2 changes: 1 addition & 1 deletion src/Cli/CliInitProject.php
Original file line number Diff line number Diff line change
Expand Up @@ -102,7 +102,7 @@ public function __invoke(array $args, array $assocArgs)

WP_CLI::log('--------------------------------------------------');

if (!\getenv('TEST')) {
if (!\getenv('ES_TEST')) {
WP_CLI::log((string)shell_exec('npm run start')); // phpcs:ignore
}

Expand Down
2 changes: 1 addition & 1 deletion src/Cli/CliInitTheme.php
Original file line number Diff line number Diff line change
Expand Up @@ -95,7 +95,7 @@ public function __invoke(array $args, array $assocArgs)

WP_CLI::log('--------------------------------------------------');

if (!\getenv('TEST')) {
if (!\getenv('ES_TEST')) {
WP_CLI::log((string)shell_exec('npm run start')); // phpcs:ignore
}

Expand Down
4 changes: 2 additions & 2 deletions src/Helpers/Components.php
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,7 @@ public static function render(string $component, array $attributes = [], string
if (empty($parentPath)) {
$parentPath = \dirname(__DIR__, 5);

if (\getenv('TEST')) {
if (\getenv('ES_TEST')) {
$parentPath = \dirname(__DIR__, 2);
}
}
Expand All @@ -107,7 +107,7 @@ public static function render(string $component, array $attributes = [], string
} else {
$blocksPath = AbstractBlocks::PATH_BLOCKS_PARENT;

if (\getenv('TEST')) {
if (\getenv('ES_TEST')) {
$blocksPath = AbstractBlocks::PATH_BLOCKS_PARENT_TESTS;
}

Expand Down
4 changes: 2 additions & 2 deletions src/Manifest/AbstractManifest.php
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ abstract class AbstractManifest implements ServiceInterface, ManifestInterface
*/
public function setAssetsManifestRaw(): void
{
if (\defined('WP_CLI') && !\getenv('TEST')) {
if (\defined('WP_CLI') && !\getenv('ES_TEST')) {
return;
}

Expand Down Expand Up @@ -73,7 +73,7 @@ function ($manifestItem) {
*/
public function getAssetsManifestItem(string $key): string
{
if (\defined('WP_CLI') && !\getenv('TEST')) {
if (\defined('WP_CLI') && !\getenv('ES_TEST')) {
return '';
}

Expand Down
2 changes: 1 addition & 1 deletion src/Setup/UpdateCli.php
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,7 @@ public function __invoke(array $args, array $assocArgs)

$setupFilename = 'setup.json';

if (\getenv('TEST') !== false) {
if (\getenv('ES_TEST') !== false) {
$setupFilename = $this->getProjectConfigRootPath() . '/cliOutput/setup.json';
}

Expand Down
8 changes: 4 additions & 4 deletions tests/Cli/AbstractCliTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -193,13 +193,13 @@ public function getDoc(): array
$abstractMock = new AbstractTest('test');

// The test one is covered. Let's see if we can get the one that will be used
putenv('TEST');
putenv('ES_TEST');
$output = $abstractMock->getLibsPath('test');

$this->assertIsString($output);
$this->assertStringContainsString('/vendor/infinum/eightshift-libs/test', $output);

putenv('TEST=1');
putenv('ES_TEST=1');
});


Expand All @@ -213,15 +213,15 @@ public function getDoc(): array


test('Project config root path works if dev is false', function() {
putenv('TEST');
putenv('ES_TEST');
$abstractMock = new AbstractTest('test');

$outputProd = $abstractMock->getProjectConfigRootPath(false);

$this->assertIsString($outputProd);
$this->assertSame('/', $outputProd);

putenv('TEST=1');
putenv('ES_TEST=1');
});


Expand Down

0 comments on commit f1ca5bf

Please sign in to comment.