DataSift\Storyplayer\CommandLib\SshClientTest::testMustProvideUsernameToRunCommands PHP Method

testMustProvideUsernameToRunCommands() public method

    public function testMustProvideUsernameToRunCommands()
    {
        // ----------------------------------------------------------------
        // setup your test
        // our mocked $st
        $st = Mockery::mock("DataSift\\Storyplayer\\PlayerLib\\StoryTeller");
        // our fake Output for logging purposes
        $output = Mockery::mock("DataSift\\Storyplayer\\Output");
        $output->shouldReceive('logPhaseActivity');
        // our fake injectables container
        $injectables = new Injectables();
        $injectables->dataFormatter = new DataFormatter();
        $injectables->dataFormatter->setIsVerbose(true);
        $injectables->output = $output;
        // our mocked $st needs to do things too
        //
        // we have to put this down here, because we need to pass $st into
        // our mocked CommandRunner
        $st->shouldReceive('startAction')->once()->andReturn(new Action_LogItem($injectables, 1));
        // our test subject
        $obj = new SshClient($st);
        // ----------------------------------------------------------------
        // perform the change
        $caughtException = false;
        try {
            $result = $obj->runCommand('ls /tmp');
        } catch (E4xx_NeedSshUsername $e) {
            $caughtException = true;
        }
        // ----------------------------------------------------------------
        // test the results
        $this->assertTrue($caughtException);
        // all done
        Mockery::close();
    }