DataSift\Storyplayer\PlayerLib\Action_LogItem::getOpenAction PHP Method

getOpenAction() public method

public getOpenAction ( ) : Action_LogItem | null
return Action_LogItem | null
    public function getOpenAction()
    {
        // do we have an active nested action?
        if (isset($this->nestedAction) && $this->nestedAction->getIsOpen()) {
            // ask it to figure out what to return
            return $this->nestedAction->getOpenAction();
        }
        // are we the open action?
        if ($this->getIsOpen()) {
            return $this;
        }
        // if we get here, then there is no current open action
        return null;
    }

Usage Example

Example #1
0
 /**
  * @covers DataSift\Storyplayer\PlayerLib\Action_LogItem::startStep
  * @covers DataSift\Storyplayer\PlayerLib\Action_LogItem::endStep
  * @covers DataSift\Storyplayer\PlayerLib\Action_LogItem::getOpenAction
  */
 public function testAddAStepWithoutUsingACallable()
 {
     // ----------------------------------------------------------------
     // 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->assertTrue($obj->getIsOpen());
     // ----------------------------------------------------------------
     // perform the change
     $obj->startStep($startMsg2);
     $nestedObj = $obj->getOpenAction();
     $this->assertNotSame($obj, $nestedObj);
     $this->assertTrue($nestedObj->getIsOpen());
     $obj->endStep();
     $this->assertTrue($nestedObj->getIsComplete());
     // ----------------------------------------------------------------
     // test the results
     Mockery::close();
 }