getOutput() public method

public getOutput ( ) : Output
return DataSift\Storyplayer\Output
Ejemplo n.º 1
0
 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
 }
Ejemplo n.º 2
0
 /**
  * @param string $type
  */
 public function runHandlers(StoryTeller $st, $type)
 {
     // shorthand
     $output = $st->getOutput();
     // Do we have any persistent tables to cleanup?
     $runtimeConfig = $st->getRuntimeConfig();
     if (!isset($runtimeConfig->storyplayer, $runtimeConfig->storyplayer->tables)) {
         // there are no tables at all
         return;
     }
     // if we get here, then we know that there are persistent
     // tables that we need to cleanup
     // this will keep track of any tables that have no associated
     // cleanup handler
     $missingCleanupHandlers = [];
     // Take a look at all of our process list tables
     foreach ($runtimeConfig->storyplayer->tables as $key => $value) {
         $className = "cleanup" . ucfirst($key);
         try {
             $st->{$className}($key)->{$type}();
         } catch (E5xx_NoMatchingActions $e) {
             // We don't know about a cleanup module for this, SHOUT LOUDLY
             $missingCleanupHandlers[] = "Missing cleanup module for '{$key}'" . PHP_EOL;
         }
     }
     // Now we've cleaned everything up, save the runtime config
     $st->saveRuntimeConfig();
     // If we have any missing cleanup handlers, output it to the screen
     // and exit with an error code
     if (count($missingCleanupHandlers)) {
         foreach ($missingCleanupHandlers as $msg) {
             $output->logCliError($msg);
         }
         exit(1);
     }
 }
Ejemplo n.º 3
0
 /**
  *
  * @param  StoryTeller $st
  * @param  Injectables $injectables
  * @param  Phase       $phase
  * @param  boolean     $isActive
  * @return Phase_Result
  */
 public function playPhase(StoryTeller $st, Injectables $injectables, Phase $phase, $isActive, $thingBeingPlayed = null)
 {
     // shorthand
     $output = $st->getOutput();
     $phaseName = $phase->getPhaseName();
     // run the phase if we're allowed to
     if ($isActive) {
         $st->setCurrentPhase($phase);
         $phaseResult = $phase->doPhase($thingBeingPlayed);
     } else {
         $phaseResult = new Phase_Result($phaseName);
         $phaseResult->setContinuePlaying($phaseResult::SKIPPED);
         $output->logPhaseSkipped($phaseName, self::MSG_PHASE_NOT_ACTIVE);
     }
     // close off any open log actions
     $st->closeAllOpenActions();
     // stop any running test devices
     if (!$st->getPersistDevice()) {
         $st->stopDevice();
     }
     // close off any log actions left open by closing down
     // the test device
     $st->closeAllOpenActions();
     // all done
     return $phaseResult;
 }
Ejemplo n.º 4
0
 public function play(StoryTeller $st, Injectables $injectables)
 {
     // shorthand
     $output = $st->getOutput();
     // we're going to use this to play our setup and teardown phases
     $phasesPlayer = new PhaseGroup_Player();
     // load our story
     $story = Story_Loader::loadStory($this->storyFilename);
     $st->setStory($story);
     // does our story want to keep the test device open between
     // phases?
     if ($story->getPersistDevice()) {
         $st->setPersistDevice();
     }
     // set default callbacks up
     $story->setDefaultCallbacks();
     // make sure we start with a brand new checkpoint
     $st->setCheckpoint(new Story_Checkpoint($st));
     // tell the outside world what we're doing
     $activity = "Running story";
     $name = $story->getCategory() . ' > ' . $story->getGroupAsString() . ' > ' . $story->getName();
     $output->startPhaseGroup($activity, $name);
     // run the phases before the story truly starts
     $phasesPlayer->playPhases($activity, $st, $injectables, $this->startupPhases, $story);
     // what happened?
     $result = $story->getResult();
     if (!$result->getPhaseGroupSucceeded()) {
         // make sure the result has the story's filename in
         $result->filename = $this->storyFilename;
         // announce the results
         $output->endPhaseGroup($result);
         // all done
         return;
     }
     // run the phases in the 'story' section
     $phasesPlayer->playPhases($activity, $st, $injectables, $this->storyPhases, $story);
     // grab the result at this point
     $result = clone $story->getResult();
     // run the shutdown phase
     $phasesPlayer->playPhases($activity, $st, $injectables, $this->shutdownPhases, $story);
     // do we also need to look at any failures that happened during
     // the shutdown phase?
     if ($result->getPhaseGroupSucceeded()) {
         $result = $story->getResult();
     }
     // make sure the result has the story's filename in
     $result->filename = $this->storyFilename;
     // announce the results
     $output->endPhaseGroup($result);
     // all done
 }