public function doPhase($thingBeingPlayed = null)
{
// shorthand
$st = $this->st;
// our return value
$phaseResult = $this->getNewPhaseResult();
// find out what we need to be doing
$testEnvironmentConfig = $st->getTestEnvironmentConfig();
// are there any machines to create?
if (empty($testEnvironmentConfig)) {
// nothing to do
$phaseResult->setContinuePlaying();
return $phaseResult;
}
// create the environments
try {
foreach ($testEnvironmentConfig->groups as $group) {
// create the machine(s) in this environment, including:
//
// * building any virtual machines
// * registering in the Hosts table
// * registering in the Roles table
$hostAdapter = HostLib::getHostAdapter($st, $group->type);
$hostAdapter->createHost($group);
// provision software onto the machines we've just
// created
if (isset($group->provisioning)) {
$provAdapter = ProvisioningLib::getProvisioner($st, $group->provisioning->engine);
$provDef = $provAdapter->buildDefinitionFor($group);
$provAdapter->provisionHosts($provDef, $group->provisioning);
}
}
$st->usingTargetsTable()->addCurrentTestEnvironment();
$phaseResult->setContinuePlaying();
} catch (E5xx_ActionFailed $e) {
$phaseResult->setPlayingFailed($phaseResult::FAILED, $e->getMessage(), $e);
} catch (E5xx_ExpectFailed $e) {
$phaseResult->setPlayingFailed($phaseResult::FAILED, $e->getMessage(), $e);
} catch (E5xx_NotImplemented $e) {
$phaseResult->setPlayingFailed($phaseResult::INCOMPLETE, $e->getMessage(), $e);
} catch (Exception $e) {
$phaseResult->setPlayingFailed($phaseResult::ERROR, $e->getMessage() . PHP_EOL . PHP_EOL . $e->getTraceAsString(), $e);
}
// all done
return $phaseResult;
}