diff --git a/RoboFile.php b/RoboFile.php index 7791240..d893b83 100644 --- a/RoboFile.php +++ b/RoboFile.php @@ -25,7 +25,6 @@ public function run( ) { // Bootstrap the environment -// \Migrator\Step\StepParent::fillDynamicEnvironmentFromEnv(); $dynamicEnv = new \Migrator\Step\DynamicEnvironment(); $dynamicEnv->fillDynamicEnvironmentFromEnv(); diff --git a/tests/StepParentTest.php b/tests/StepParentTest.php index 684f642..1cd422d 100644 --- a/tests/StepParentTest.php +++ b/tests/StepParentTest.php @@ -3,6 +3,7 @@ namespace Migrator\Step; use Migrator\LagoonUtilityBelt; +use Migrator\LagoonUtilityBeltInterface; use Migrator\RunnerArgs; use PHPUnit\Framework\TestCase; @@ -73,4 +74,49 @@ public function testJSONPAYLOADFILL() { } + + /** + * This test looks at derived classes/child classes and ensures that they have access to the step-parent's dynamic + * environment functionality - which they should, even the inheretence hierarchy + * + * @return void + * @throws \Exception + */ + public function testDynamicEnvironmentInChildren() { + $dynamicEnv = new DynamicEnvironment(); + $args = new RunnerArgs(); + + $dynamicutilityBelt = new class() implements LagoonUtilityBeltInterface + { + public function deployEnvironment($project, $environment, $variables, $bulkName = NULL){} + public function processWaitForDeploymentToComplete($project, $environment, $id, $passFailedDeploymentIfTextExists){} + public function getBuildLogByBuildName($project, $environment, $buildId){} + public function startTaskInEnvironment($project, $environment, $taskName){} + public function setDeployTargetForEnvironment($project, $environmentName, $openshiftId){} + public function refreshLagoonToken(){} + public function getProjectDetailsByName($project){} + public function getEnvironmentDetails($project, $environment){} + public function whoIsMe(){} + public function getLagoonToken(){} + public function waitForDeploymentToComplete($project, $environment, $deploymentId){} + }; + + $dynamicclass = new class($dynamicutilityBelt, $args, $dynamicEnv) extends StepParent + { + + protected function runImplementation(array $args) + { + $this->dynamicEnvironment->setVariable("thecalliscomingfrom", "insidethehouse"); + } + + public function callMeToTest() { + $this->run([]); + } + }; + + $dynamicclass->callMeToTest(); + + $this->assertEquals("insidethehouse", $dynamicEnv->getVariable("thecalliscomingfrom")); + } + }