DataSift\Storyplayer\PlayerLib\Action_LogItemTest::testAddAStep PHP Method

testAddAStep() public method

public testAddAStep ( )
    public function testAddAStep()
    {
        // ----------------------------------------------------------------
        // 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);
        $this->assertSame($obj, $obj->getOpenAction());
        // make sure the message started
        $this->assertTrue($obj->getIsOpen());
        // what is our sub-step?
        $func = function () {
            return 1;
        };
        // ----------------------------------------------------------------
        // perform the change
        $return = $obj->addStep($startMsg2, $func);
        // ----------------------------------------------------------------
        // test the results
        // we should have a return value from our callback
        $this->assertEquals(1, $return);
        // our unit under test should be the open action
        // (i.e. there shouldn't be an open sub-action)
        $this->assertSame($obj, $obj->getOpenAction());
        Mockery::close();
    }