DataSift\Storyplayer\PlayerLib\StoryTeller::stopDevice PHP Method

stopDevice() public method

public stopDevice ( ) : void
return void
    public function stopDevice()
    {
        // get the browser adapter
        $adapter = $this->getDeviceAdapter();
        // stop the web browser
        if (!$adapter) {
            // nothing to do
            return;
        }
        // what are we doing?
        $log = $this->startAction('stop the test device');
        // do we have a deviceTeardown() phase?
        //
        // we need to run this BEFORE we stop the device, otherwise
        // the deviceTeardown() phase has no device to work with
        if (isset($this->story) && $this->story->hasDeviceTeardown()) {
            // get the callbacks to call
            $callbacks = $this->story->getDeviceTeardown();
            // make the call
            //
            // we do not need to wrap these in a TRY/CATCH block,
            // as we are already running inside one of the story's
            // phases
            foreach ($callbacks as $callback) {
                call_user_func($callback, $this);
            }
        }
        // stop the browser
        $adapter->stop();
        // destroy the adapter
        $this->setDeviceAdapter(null);
        // all done
        $log->endAction();
    }

Usage Example

Esempio n. 1
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;
 }