示例#1
0
 /**
  * @depends test_doRun
  * @covers ::getStatus
  */
 public function test_getStatus()
 {
     $this->assertTrue($this->Command->open($this->Input), 'ShellCommand::open() should return TRUE');
     $this->assertTrue($this->Command->getStatus('running'), 'ShellCommand::getStatus() should return TRUE');
     # Invalid arguments
     try {
         $this->Command->getStatus(null);
         $this->fail('Failed to generate exception with invalid arguments');
     } catch (InvalidArgumentException $e) {
     }
 }
示例#2
0
 /**
  * @coversNothing
  */
 public function test_doRun()
 {
     // Only Windows
     if (DIRECTORY_SEPARATOR != '\\') {
         return true;
     }
     $Expected = 'foo';
     $this->assertEquals(0, $this->Command->run($this->Input, $this->Output), 'ShellCommand::run() returned an invalid result');
     $this->assertEquals($Expected, $this->Output->stdOut->getContents(), 'ShellCommand::doRun() Failed to process command output');
     $this->assertEmpty($this->Output->stdErr->getContents(), 'ShellCommand::doRun() Failed to process command error');
 }
示例#3
0
文件: install.php 项目: mast3rpee/blw
         if ($path->isDir()) {
             continue;
         } elseif ($path->isFile()) {
             if (!is_dir($Dir = str_replace($Src, $Dest, $path->getPath()))) {
                 mkdir($Dir);
             }
             copy($path->getPathname(), str_replace($Src, $Dest, $path->getPathname()));
         }
     }
 };
 // #####################
 // RUN COMPOSER
 // #####################
 $Print('Running Composer...');
 $ShellInput = new Input(new Handle(fopen('data:text/plain,', 'r')));
 $Composer = new ShellCommand('composer dumpautoload -o', new Config(array('Timeout' => 60, 'CWD' => dirname(__DIR__), 'Environment' => null, 'Extras' => array())), $Command->getMediator(), $Command->getMediatorID());
 // Check results
 if ($code = $Composer->run($ShellInput, $Output)) {
     return $code;
 }
 $Output->write("\r\n");
 // #####################
 // COMPILE APPLICATION
 // #####################
 $Print('Compiling application...');
 @unlink(BLW_DIR . 'build' . DIRECTORY_SEPARATOR . 'BLW.phar');
 @unlink(BLW_DIR . 'build' . DIRECTORY_SEPARATOR . 'BLW.tar.gz');
 $Output->write("-Collecting files\r\n");
 $Output->write('[--------------------------------------------------]');
 // Create PHAR
 $Compiler = new Compiler(new GenericFile(BLW_DIR . 'build'), new GenericFile(BLW_DIR), new GenericFile(BLW_DIR . 'temp'), $Command->getMediator());
示例#4
0
文件: test.php 项目: mast3rpee/blw
use BLW\Model\Stream\Handle;
Application::configure();
Application::run(function (BLW\Type\Command\IInput $Input, BLW\Type\Command\IOutput $Output, BLW\Type\Command\ICommand $Command) {
    $Print = function ($Message) use(&$Output, &$Command) {
        $Output->write("{$Message}\r\n");
        $Command->Config['Logger']->debug($Message);
    };
    // #####################
    // TEST LIBRARY
    // #####################
    $Print('Testing BLW Library...');
    // Run framework tests
    $ShellInput = new Input(new Handle(fopen('data:text/plain,', 'r')));
    $ShellInput->Options[] = new Option('testsuite', 'Types');
    $ShellInput->Options[] = new Option('coverage-php', 'temp/coverage-types.serialized');
    $PHPUnit = new ShellCommand('phpunit', new Config(array('Timeout' => 60, 'CWD' => dirname(__DIR__), 'Environment' => null, 'Extras' => array())), $Command->getMediator(), $Command->getMediatorID());
    // Check results
    if ($code = $PHPUnit->run($ShellInput, $Output)) {
        return $code;
    }
    // Run library tests
    $ShellInput = new Input(new Handle(fopen('data:text/plain,', 'r')));
    $ShellInput->Options[] = new Option('testsuite', 'Models');
    $ShellInput->Options[] = new Option('coverage-php', 'temp/coverage-models.serialized');
    $PHPUnit->run($ShellInput, $Output);
    // Merge coverage files
    // ...
    $Print('Finished testing.');
    // Done
    return 0;
});
示例#5
0
 /**
  * Sends a JSON command to PhantomJS
  *
  * @codeCoverageIngore
  *
  * @param array $Command
  *            Command to send
  * @param integer $Timeout
  *            Timeout for reads / writes to process.
  * @return string Output of command. <code>FALSE</code> on error.
  */
 private function _sendJSON(array $Command, $Timeout = 10)
 {
     // `evaluate` command
     $Command = json_encode($Command);
     // Add end of transmition marker
     $Command .= "\r\n";
     // Run Processes
     $Input = new CommandInput(new StringStream($Command));
     $Output = new CommandOutput(new StringStream($stdOut, IFile::WRITE | IFile::TRUNCATE), new StringStream($stdErr, IFile::WRITE | IFile::TRUNCATE));
     // Transfer output
     try {
         $this->_Process->transferStreams($Input, $Output, $Timeout);
         // @codeCoverageIgnoreStart
     } catch (CommandException $e) {
         // Restart PhantomJS just to be sure
         $this->phantomRestart();
         return false;
     }
     // @codeCoverageIgnoreEnd
     unset($Input, $Output);
     // Normalize output
     $stdOut = substr($stdOut, strpos($stdOut, '{'), strrpos($stdOut, '}') - strlen($stdOut) + 1);
     // Done
     return $stdOut;
 }
示例#6
0
 /**
  * Constructor
  *
  * @param mixed $Command
  *            Command to run.
  * @param IConfig $Config
  *            Command configuration.
  * @param IMediator $Mediator
  *            Mediator for command.
  * @param string $ID
  *            Command Name / Label
  */
 public function __construct($Command, IConfig $Config, IMediator $Mediator = null, $ID = null)
 {
     // Parent constructor
     parent::__construct($Command, $Config, $Mediator, $ID);
     // Bypass CMD
     $Config['Extras']['bypass_shell'] = true;
 }