DataSift\Storyplayer\PlayerLib\Action_LogItem::endAction PHP Метод

endAction() публичный Метод

public endAction ( mixed $message = null )
$message mixed
    public function endAction($message = null)
    {
        // close any open sub-actions
        $this->closeAllOpenSubActions();
        // remember when the action completed
        $this->endTime = microtime(true);
        // do we any output to log?
        if ($message == null || empty($message)) {
            return;
        }
        // convert to string if required
        //
        // if the user hasn't used -V from the command-line, then this
        // will also truncate the output
        $text = $this->dataFormatter->convertData($message);
        // log the result
        $this->writeToLog('... ' . $text);
    }

Usage Example

Пример #1
0
 /**
  * @covers DataSift\Storyplayer\PlayerLib\Action_LogItem::endAction
  * @covers DataSift\Storyplayer\PlayerLib\Action_LogItem::closeAllOpenSubActions
  * @covers DataSift\Storyplayer\PlayerLib\Action_LogItem::getStartTime
  * @covers DataSift\Storyplayer\PlayerLib\Action_LogItem::getIsComplete
  */
 public function testEndingAnActionEndsAllNestedActionsToo()
 {
     // ----------------------------------------------------------------
     // setup your test
     // the messages we are logging
     $startMsg1 = "This is a test message";
     $startMsg2 = "This is the nested test message";
     // our DI container
     $i = new Injectables();
     // our mocked output object
     $i->output = Mockery::mock("DataSift\\Storyplayer\\Output");
     $i->output->shouldReceive('logPhaseActivity')->once()->with($startMsg1, null);
     $i->output->shouldReceive('logPhaseActivity')->once()->with('  ' . $startMsg2, null);
     // our real data formatter
     $i->dataFormatter = new DataFormatter();
     // our unit under test
     $obj = new Action_LogItem($i, 1);
     $obj->startAction($startMsg1);
     // make sure the message started
     $this->assertNotNull($obj->getStartTime());
     // start our nested actions
     $nestedObj1 = $obj->newNestedAction();
     $nestedObj1->startAction($startMsg2);
     $nestedObj2 = $obj->newNestedAction();
     $this->assertTrue($nestedObj1 instanceof Action_LogItem);
     $this->assertEquals(2, $nestedObj1->getNestLevel());
     $this->assertTrue($nestedObj2 instanceof Action_LogItem);
     $this->assertEquals(3, $nestedObj2->getNestLevel());
     // ----------------------------------------------------------------
     // perform the change
     $obj->endAction();
     // ----------------------------------------------------------------
     // test the results
     $this->assertTrue($nestedObj2->getIsComplete());
     $this->assertTrue($nestedObj1->getIsComplete());
     $this->assertTrue($obj->getIsComplete());
     Mockery::close();
 }