Skip to content

Commit

Permalink
Merge pull request #16 from grasmash/patch-2
Browse files Browse the repository at this point in the history
Add Acquia Lando support
  • Loading branch information
danepowell authored Apr 15, 2021
2 parents 47417e9 + f8e64a0 commit 63b1bd0
Show file tree
Hide file tree
Showing 3 changed files with 48 additions and 2 deletions.
3 changes: 2 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
@@ -1,2 +1,3 @@
vendor
.phpcs-cache
.phpcs-cache
.idea
23 changes: 22 additions & 1 deletion src/AcquiaDrupalEnvironmentDetector.php
Original file line number Diff line number Diff line change
Expand Up @@ -222,11 +222,32 @@ public static function getSiteName($site_path) {
return str_replace('sites/', '', $site_path);
}

/**
* Is this a Lando environment using the Acquia recipe.
*/
public static function isAcquiaLandoEnv() {
return getenv('AH_SITE_ENVIRONMENT') === 'LANDO';
}

/**
* Is this a Lando environment.
*/
public static function isLandoEnv() {
return getenv('LANDO') === 'ON';
}

/**
* Get Lando info.
*/
public static function getLandoInfo() {
return getenv('LANDO_INFO');
}

/**
* If this isn't a Cloud environment, assume it's local.
*/
public static function isLocalEnv() {
return !self::isAhEnv();
return !self::isAhEnv() || self::isAcquiaLandoEnv();
}

}
24 changes: 24 additions & 0 deletions tests/EnvironmentDetectorTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -68,6 +68,21 @@ public function testIsAhOdeEnv($ah_site_env, $expected_env) {
$this::assertEquals($expected_env === 'ode', AcquiaDrupalEnvironmentDetector::isAhOdeEnv());
}

/**
* Tests EnvironmentDetector::isAcquiaLandoEnv().
*
* @param string $ah_site_env
* The name of the site environment.
* @param string $expected_env
* Environment type.
*
* @dataProvider providerTestIsEnv
*/
public function testIsAcquiaLandoEnv($ah_site_env, $expected_env) {
putenv("AH_SITE_ENVIRONMENT=$ah_site_env");
$this::assertEquals($expected_env === 'lando', AcquiaDrupalEnvironmentDetector::isAcquiaLandoEnv());
}

/**
* Provides values to testIsAhEnv tests.
*
Expand All @@ -90,7 +105,16 @@ public function providerTestIsEnv() {
['02live', 'prod'],
['ode1', 'ode'],
['ode2', 'ode'],
['LANDO', 'lando'],
];
}

/**
* Tests EnvironmentDetector::isLandoEnv().
*/
public function testIsLandoEnv() {
putenv("LANDO=ON");
$this::assertTrue(AcquiaDrupalEnvironmentDetector::isLandoEnv());
}

}

0 comments on commit 63b1bd0

Please sign in to comment.