Skip to content

Commit 1ea843f

Browse files
committed
swap manual checks on ENVIRONMENT
1 parent d9efad5 commit 1ea843f

25 files changed

Lines changed: 71 additions & 43 deletions

system/CLI/CLI.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -656,7 +656,7 @@ public static function strlen(?string $string): int
656656
*/
657657
public static function streamSupports(string $function, $resource): bool
658658
{
659-
if (ENVIRONMENT === 'testing') {
659+
if (service('environmentdetector')->isTesting()) {
660660
// In the current setup of the tests we cannot fully check
661661
// if the stream supports the function since we are using
662662
// filtered streams.

system/CLI/InputOutput.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,7 @@ public function __construct()
4242
public function input(?string $prefix = null): string
4343
{
4444
// readline() can't be tested.
45-
if ($this->readlineSupport && ENVIRONMENT !== 'testing') {
45+
if ($this->readlineSupport && ! service('environmentdetector')->isTesting()) {
4646
return readline($prefix); // @codeCoverageIgnore
4747
}
4848

system/Commands/Database/CreateDatabase.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -87,7 +87,7 @@ public function run(array $params)
8787
$config = config(Database::class);
8888

8989
// Set to an empty database to prevent connection errors.
90-
$group = ENVIRONMENT === 'testing' ? 'tests' : $config->defaultGroup;
90+
$group = service('environmentdetector')->isTesting() ? 'tests' : $config->defaultGroup;
9191

9292
$config->{$group}['database'] = '';
9393

system/Commands/Database/MigrateRefresh.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -74,7 +74,7 @@ public function run(array $params)
7474
{
7575
$params['b'] = 0;
7676

77-
if (ENVIRONMENT === 'production') {
77+
if (service('environmentdetector')->isProduction()) {
7878
// @codeCoverageIgnoreStart
7979
$force = array_key_exists('f', $params) || CLI::getOption('f');
8080

system/Commands/Database/MigrateRollback.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -72,7 +72,7 @@ class MigrateRollback extends BaseCommand
7272
*/
7373
public function run(array $params)
7474
{
75-
if (ENVIRONMENT === 'production') {
75+
if (service('environmentdetector')->isProduction()) {
7676
// @codeCoverageIgnoreStart
7777
$force = array_key_exists('f', $params) || CLI::getOption('f');
7878

system/Commands/Database/MigrateStatus.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -92,7 +92,7 @@ public function run(array $params)
9292
$status = [];
9393

9494
foreach (array_keys($namespaces) as $namespace) {
95-
if (ENVIRONMENT !== 'testing') {
95+
if (! service('environmentdetector')->isTesting()) {
9696
// Make Tests\\Support discoverable for testing
9797
$this->ignoredNamespaces[] = 'Tests\Support'; // @codeCoverageIgnore
9898
}

system/Commands/Translation/LocalizationFinder.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -61,7 +61,7 @@ public function run(array $params)
6161
$currentDir = APPPATH;
6262
$this->languagePath = $currentDir . 'Language';
6363

64-
if (ENVIRONMENT === 'testing') {
64+
if (service('environmentdetector')->isTesting()) {
6565
$currentDir = SUPPORTPATH . 'Services' . DIRECTORY_SEPARATOR;
6666
$this->languagePath = SUPPORTPATH . 'Language';
6767
}

system/Commands/Translation/LocalizationSync.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -85,7 +85,7 @@ public function run(array $params)
8585
return EXIT_USER_INPUT;
8686
}
8787

88-
if (ENVIRONMENT === 'testing') {
88+
if (service('environmentdetector')->isTesting()) {
8989
$this->languagePath = SUPPORTPATH . 'Language';
9090
}
9191

system/Database/Config.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -61,7 +61,7 @@ public static function connect($group = null, bool $getShared = true)
6161
$dbConfig = config(DbConfig::class);
6262

6363
if ($group === null) {
64-
$group = (ENVIRONMENT === 'testing') ? 'tests' : $dbConfig->defaultGroup;
64+
$group = service('environmentdetector')->isTesting() ? 'tests' : $dbConfig->defaultGroup;
6565
}
6666

6767
assert(is_string($group));

system/Database/MigrationRunner.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -448,7 +448,7 @@ public function findMigrations(): array
448448
$migrations = [];
449449

450450
foreach ($namespaces as $namespace) {
451-
if (ENVIRONMENT !== 'testing' && $namespace === 'Tests\Support') {
451+
if (! service('environmentdetector')->isTesting() && $namespace === 'Tests\Support') {
452452
continue;
453453
}
454454

@@ -985,7 +985,7 @@ protected function migrate($direction, $migration): bool
985985
$instance = new $class(Database::forge($this->db));
986986
$group = $instance->getDBGroup() ?? $this->group;
987987

988-
if (ENVIRONMENT !== 'testing' && $group === 'tests' && $this->groupFilter !== 'tests') {
988+
if (! service('environmentdetector')->isTesting() && $group === 'tests' && $this->groupFilter !== 'tests') {
989989
// @codeCoverageIgnoreStart
990990
$this->groupSkip = true;
991991

0 commit comments

Comments
 (0)