DataSift\Storyplayer\CommandLib\CommandRunnerTest::testCapturesReturnCodeFromTheCommand PHP Метод

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

    public function testCapturesReturnCodeFromTheCommand()
    {
        // ----------------------------------------------------------------
        // setup your test
        // our test subject
        $obj = new CommandRunner();
        // a fake logging object
        $log = Mockery::mock("DataSift\\Storyplayer\\PlayerLib\\Action_LogItem");
        $log->shouldReceive('endAction')->once();
        $log->shouldReceive('captureOutput')->once();
        // our mocked $st
        $st = Mockery::mock("DataSift\\Storyplayer\\PlayerLib\\StoryTeller");
        $st->shouldReceive('startAction')->andReturn($log);
        // our example command
        $helperCmd = "echo fred ; exit 1";
        // ----------------------------------------------------------------
        // perform the change
        $result = $obj->runSilently($st, $helperCmd);
        // ----------------------------------------------------------------
        // test the results
        $this->assertTrue($result instanceof CommandResult);
        $this->assertEquals(1, $result->returnCode);
    }