Skip to content

Commit

Permalink
Run all tests in all 3 envs
Browse files Browse the repository at this point in the history
  • Loading branch information
back-2-95 committed Mar 1, 2020
1 parent 8a3bd97 commit bd07d7b
Show file tree
Hide file tree
Showing 6 changed files with 74 additions and 10 deletions.
20 changes: 15 additions & 5 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -30,11 +30,21 @@
"prefer-stable": true,
"scripts": {
"test": [
"phpunit --debug --verbose --configuration tests/AmazeeIoLegacy.xml",
"phpunit --debug --verbose --configuration tests/Lagoon.xml",
"phpunit --debug --verbose --configuration tests/Lando.xml",
"phpunit --debug --verbose --configuration tests/Pantheon.xml",
"phpunit --debug --verbose --configuration tests/Wodby.xml"
"APP_ENV=dev phpunit --debug --verbose --configuration tests/AmazeeIoLegacy.xml",
"APP_ENV=test phpunit --debug --verbose --configuration tests/AmazeeIoLegacy.xml",
"APP_ENV=prod phpunit --debug --verbose --configuration tests/AmazeeIoLegacy.xml",
"APP_ENV=dev phpunit --debug --verbose --configuration tests/Lagoon.xml",
"APP_ENV=test phpunit --debug --verbose --configuration tests/Lagoon.xml",
"APP_ENV=prod phpunit --debug --verbose --configuration tests/Lagoon.xml",
"APP_ENV=dev phpunit --debug --verbose --configuration tests/Lando.xml",
"APP_ENV=test phpunit --debug --verbose --configuration tests/Lando.xml",
"APP_ENV=prod phpunit --debug --verbose --configuration tests/Lando.xml",
"APP_ENV=dev phpunit --debug --verbose --configuration tests/Pantheon.xml",
"APP_ENV=test phpunit --debug --verbose --configuration tests/Pantheon.xml",
"APP_ENV=prod phpunit --debug --verbose --configuration tests/Pantheon.xml",
"APP_ENV=dev phpunit --debug --verbose --configuration tests/Wodby.xml",
"APP_ENV=test phpunit --debug --verbose --configuration tests/Wodby.xml",
"APP_ENV=prod phpunit --debug --verbose --configuration tests/Wodby.xml"
]
}
}
18 changes: 15 additions & 3 deletions src/EnvDefaults/AbstractDefaults.php
Original file line number Diff line number Diff line change
Expand Up @@ -6,10 +6,22 @@ abstract class AbstractDefaults {
protected $config = [];
protected $settings = [];

public function getDefaults() {
public function getDefaults() : array {
$contrib_module_defaults = $this->getContribModuleDefaults();

$config = array_merge($this->config, $contrib_module_defaults['config']);
$settings = array_merge($this->settings, $contrib_module_defaults['settings']);

return [
'config' => $config,
'settings' => $settings,
];
}

protected function getContribModuleDefaults() : array {
return [
'config' => $this->config,
'settings' => $this->settings,
'config' => [],
'settings' => [],
];
}
}
10 changes: 10 additions & 0 deletions src/EnvDefaults/DevDefaults.php
Original file line number Diff line number Diff line change
Expand Up @@ -23,4 +23,14 @@ public function __construct()
$this->config = $config;
$this->settings = $settings;
}

protected function getContribModuleDefaults() : array {
// Simple Environment Indicator.
$settings['simple_environment_indicator'] = 'Black Development';

return [
'config' => [],
'settings' => $settings,
];
}
}
10 changes: 10 additions & 0 deletions src/EnvDefaults/ProdDefaults.php
Original file line number Diff line number Diff line change
Expand Up @@ -19,4 +19,14 @@ public function __construct()

$this->config = $config;
}

protected function getContribModuleDefaults() : array {
// Simple Environment Indicator.
$settings['simple_environment_indicator'] = 'DarkRed Production';

return [
'config' => [],
'settings' => $settings,
];
}
}
10 changes: 10 additions & 0 deletions src/EnvDefaults/TestDefaults.php
Original file line number Diff line number Diff line change
Expand Up @@ -19,4 +19,14 @@ public function __construct()

$this->config = $config;
}

protected function getContribModuleDefaults() : array {
// Simple Environment Indicator.
$settings['simple_environment_indicator'] = 'Blue Testing';

return [
'config' => [],
'settings' => $settings,
];
}
}
16 changes: 14 additions & 2 deletions tests/BaseCase.php
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ abstract class BaseCase extends TestCase
protected function setUp(): void
{
if (!class_exists('Drupal')) {
eval("class Drupal { const VERSION = '8.8.1'; }");
eval("class Drupal { const VERSION = '8.8.2'; }");
}

$detector = new DrupalEnvDetector(__DIR__);
Expand Down Expand Up @@ -89,7 +89,7 @@ public function testConfigDefaults()
$app_env = getenv('APP_ENV');

$error_level = $this->config['system.logging']['error_level'];
$expect = ($app_env === DrupalEnvDetector::ENV_PRODUCTION) ? 'hide' : 'all';
$expect = ($app_env === DrupalEnvDetector::ENV_DEVELOPMENT) ? 'all' : 'hide';
$this->assertEquals($expect, $error_level);

$preprocess_css = $this->config['system.performance']['css']['preprocess'];
Expand All @@ -100,4 +100,16 @@ public function testConfigDefaults()
$expect = ($app_env === DrupalEnvDetector::ENV_DEVELOPMENT) ? 0 : 1;
$this->assertEquals($expect, $preprocess_js);
}

public function testSimpleEnvironmentIndicator()
{
$app_env = getenv('APP_ENV');
$value = $this->settings['simple_environment_indicator'] ?: FALSE;
$expect = [
'dev' => 'Black Development',
'test' => 'Blue Testing',
'prod' => 'DarkRed Production',
];
$this->assertEquals($expect[$app_env], $value);
}
}

0 comments on commit bd07d7b

Please sign in to comment.