Skip to content

Commit

Permalink
Adds some test of dynamic envs and removes comment
Browse files Browse the repository at this point in the history
  • Loading branch information
Blaize Kaye committed Jul 3, 2024
1 parent 215afb4 commit 799b89c
Show file tree
Hide file tree
Showing 2 changed files with 46 additions and 1 deletion.
1 change: 0 additions & 1 deletion RoboFile.php
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,6 @@ public function run(
) {

// Bootstrap the environment
// \Migrator\Step\StepParent::fillDynamicEnvironmentFromEnv();

$dynamicEnv = new \Migrator\Step\DynamicEnvironment();
$dynamicEnv->fillDynamicEnvironmentFromEnv();
Expand Down
46 changes: 46 additions & 0 deletions tests/StepParentTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
namespace Migrator\Step;

use Migrator\LagoonUtilityBelt;
use Migrator\LagoonUtilityBeltInterface;
use Migrator\RunnerArgs;
use PHPUnit\Framework\TestCase;

Expand Down Expand Up @@ -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"));
}

}

0 comments on commit 799b89c

Please sign in to comment.