gluon-web-remote

Web remote Administration for big size of gluon routers
git clone git://archive.git.mtrnord.blog/MTRNord/gluon-web-remote.git
Log | Files | Refs | README

ExecTest.php (1554B)


      1 <?php
      2 
      3 
      4 namespace Ssh\FunctionalTests;
      5 
      6 
      7 use Ssh\Authentication\Password;
      8 use Ssh\Configuration;
      9 use Ssh\Session;
     10 
     11 /**
     12  * @author Julius Beckmann
     13  *
     14  * @group functional
     15  *
     16  * @covers \Ssh\Exec
     17  */
     18 class ExecTest extends \PHPUnit_Framework_TestCase
     19 {
     20     public function testExecuteWhoami()
     21     {
     22         $configuration = new Configuration('localhost');
     23         $authentication = new Password(TEST_USER, TEST_PASSWORD);
     24         $session = new Session($configuration, $authentication);
     25 
     26         $exec = $session->getExec();
     27         $output = $exec->run('whoami');
     28 
     29         $this->assertEquals(TEST_USER, trim($output));
     30     }
     31 
     32     public function testExecuteMultilineOutput()
     33     {
     34         $configuration = new Configuration('localhost');
     35         $authentication = new Password(TEST_USER, TEST_PASSWORD);
     36         $session = new Session($configuration, $authentication);
     37 
     38         $exec = $session->getExec();
     39         $output = $exec->run('echo -e "a\nb\nc"');
     40 
     41         // In case our SystemUnderTest differs
     42         $output = str_replace("\r\n", "\n", $output);
     43 
     44         $this->assertEquals("a\nb\nc\n", $output);
     45     }
     46 
     47     /**
     48      * @expectedException \RuntimeException
     49      */
     50     public function testExecuteErrorOutput()
     51     {
     52         $configuration = new Configuration('localhost');
     53         $authentication = new Password(TEST_USER, TEST_PASSWORD);
     54         $session = new Session($configuration, $authentication);
     55 
     56         $exec = $session->getExec();
     57         $output = $exec->run('false');
     58 
     59         $this->assertEquals('', trim($output));
     60     }
     61 }
     62