コード例 #1
0
ファイル: ShellTest.php プロジェクト: mast3rpee/blw
 /**
  * @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
ファイル: PhantomJS.php プロジェクト: mast3rpee/blw
 /**
  * Constructor
  *
  * @see \BLW\Model\Command\Shell Command\Shell()
  *
  * @throws \BLW\Model\InvalidArgumentException If <code>$Configuration</code> is not readable.
  * @throws \RuntimeException If there is an error starting PhantomJS.
  *
  * @param \BLW\Type\IFile $Executable
  *            Path to PhantomJS executable.
  * @param \BLW\Type\IFile $ConfigFile
  *            Path to PhantomJS configuration JSON file.
  * @param \BLW\Type\IConfig $Config
  *            Engine configuration:
  *
  * <ul>
  * <li><b>Timeout</b>: <i>int</i> Communication timeout between PHP and PhantomJS process.</li>
  * <li><b>CWD</b>: <i>string</i> Current working directory for PhantomJS. <code>null</code> for current working directory.</li>
  * <li><b>Enviroment</b>: <i>array</i> Enviroment variables passed to PhantomJS. <code>null</code> for PHP enviroment variables.</li>
  * <li><b>Extras</b>: <i>array</i> Extra parameters passed to proc_open()</li>
  * </ul>
  */
 public function __construct(IFile $Executable, IFile $ConfigFile, IConfig $Config)
 {
     // Parent constructor
     parent::__construct(null, 'PhantomJS');
     switch (true) {
         // Validate ConfigFile
         case !$ConfigFile->isReadable():
             throw new InvalidArgumentException(1);
             // Validate $Config
         // Validate $Config
         case !isset($Config['Timeout']):
         case !$Config->offsetExists('CWD'):
         case !$Config->offsetExists('Environment'):
         case !$Config->offsetExists('Extras'):
             throw new InvalidArgumentException(2);
             // All okay
         // All okay
         default:
             // Properties
             $this->_Executable = $Executable;
             $this->_ConfigFile = $ConfigFile;
             $this->_Config = $Config;
             $this->_Mediator = new Mediator();
             // Start PhantomJS process
             if (!$this->phantomStart() || !$this->_Process->getStatus('running')) {
                 // @codeCoverageIgnoreStart
                 throw new RuntimeException('Unable to start PhantomJS');
                 // @codeCoverageIgnoreEnd
             }
     }
 }