DataSift\Storyplayer\Output::endPhase PHP Method

endPhase() public method

called when a story ends a phase
public endPhase ( Phase $phase, Phase_Result $phaseResult ) : void
$phase DataSift\Storyplayer\Phases\Phase the phase that has finished
$phaseResult DataSift\Storyplayer\PlayerLib\Phase_Result the result of running $phase
return void
    public function endPhase($phase, $phaseResult)
    {
        // enforce our input type
        Contract::Requires($phase instanceof Phase);
        Contract::Requires($phaseResult instanceof Phase_Result);
        // inject the captured activity into the phase
        $phaseResult->activityLog = $this->activityLog;
        $this->activityLog = [];
        // pass the phase on
        foreach ($this->plugins as $plugin) {
            $plugin->endPhase($phase, $phaseResult);
        }
    }

Usage Example

Exemplo n.º 1
0
 /**
  * @covers DataSift\Storyplayer\Output::endPhase()
  */
 public function testCanEndPhase()
 {
     // ----------------------------------------------------------------
     // setup the test
     $st = Mockery::mock("DataSift\\Storyplayer\\PlayerLib\\StoryTeller");
     $phase = new ExampleStoryPhase($st);
     $result = new Phase_Result('unit-test');
     $plugin1 = Mockery::mock("DataSift\\Storyplayer\\OutputLib\\OutputPlugin");
     $plugin1->shouldReceive('endPhase')->once()->with($phase, $result);
     $plugin2 = Mockery::mock("DataSift\\Storyplayer\\OutputLib\\OutputPlugin");
     $plugin2->shouldReceive('endPhase')->once()->with($phase, $result);
     $obj = new Output();
     $obj->usePluginInSlot($plugin1, "console");
     $obj->usePluginInSlot($plugin2, "slot1");
     // ----------------------------------------------------------------
     // perform the change
     $obj->endPhase($phase, $result);
     // ----------------------------------------------------------------
     // test the results
     Mockery::close();
 }