DataSift\Storyplayer\Output::logPhaseActivity PHP Method

logPhaseActivity() public method

called when a story logs an action
public logPhaseActivity ( string $msg, array | null $codeLine = null ) : void
$msg string the message to write to the logs / console
$codeLine array | null information about the line of code that is executing
return void
    public function logPhaseActivity($msg, $codeLine = null)
    {
        // enforce our input type
        Contract::RequiresValue($msg, is_string($msg));
        if ($codeLine) {
            Contract::RequiresValue($codeLine, is_array($codeLine));
        }
        // keep track of what was attempted, in case we need to show
        // the user what was attempted
        $this->activityLog[] = ['ts' => time(), 'text' => $msg, 'codeLine' => $codeLine, 'isOutput' => false];
        // call all of our plugins
        foreach ($this->plugins as $plugin) {
            $plugin->logPhaseActivity($msg, $codeLine);
        }
    }

Usage Example

Exemplo n.º 1
0
 /**
  * @covers DataSift\Storyplayer\Output::logPhaseActivity()
  */
 public function testCanLogPhaseActivityWithCodeLine()
 {
     // ----------------------------------------------------------------
     // setup the test
     $msg = "a unit-test is running ... do not be alarmed!";
     $codeLine = ["file" => "unit-test.php", "line" => 666, "code" => "\$st->fromUnitTests()->testAllTheThings();"];
     $plugin1 = Mockery::mock("DataSift\\Storyplayer\\OutputLib\\OutputPlugin");
     $plugin1->shouldReceive('logPhaseActivity')->once()->with($msg, $codeLine);
     $plugin2 = Mockery::mock("DataSift\\Storyplayer\\OutputLib\\OutputPlugin");
     $plugin2->shouldReceive('logPhaseActivity')->once()->with($msg, $codeLine);
     $obj = new Output();
     $obj->usePluginInSlot($plugin1, "console");
     $obj->usePluginInSlot($plugin2, "slot1");
     // ----------------------------------------------------------------
     // perform the change
     $obj->logPhaseActivity($msg, $codeLine);
     // ----------------------------------------------------------------
     // test the results
     Mockery::close();
 }