public function play(StoryTeller $st, Injectables $injectables)
{
// shorthand
$output = $st->getOutput();
// we're building / destroying a test environment
$activity = 'Creating test environment';
$testEnv = new TestEnvironment($injectables->activeTestEnvironmentName);
// we're using this to build / destroy our test environment
$phasesPlayer = new PhaseGroup_Player();
// announce what we're doing
$output->startPhaseGroup($activity, $injectables->activeTestEnvironmentName);
// run the startup phase
$phasesPlayer->playPhases($activity, $st, $injectables, $this->startupPhases, $testEnv);
$creationResult = $testEnv->getResult();
$output->endPhaseGroup($creationResult);
// what happened?
if (!$creationResult->getPhaseGroupSucceeded() && !$creationResult->getPhaseGroupSkipped()) {
$output->logCliError("failed to create test environment - cannot continue");
exit(1);
}
// now we need to play whatever runs against this
// test environment
foreach ($this->wrappedPlayers as $wrappedPlayer) {
// play the wrapped item
//
// this is normally a story
$wrappedPlayer->play($st, $injectables);
}
// announce what we're doing
$activity = 'Destroying test environment';
$output->startPhaseGroup($activity, $injectables->activeTestEnvironmentName);
// run the shutdown phase
$testEnv->resetResult();
$phasesPlayer->playPhases($activity, $st, $injectables, $this->shutdownPhases, $testEnv);
$output->endPhaseGroup($testEnv->getResult());
// all done
}