コード例 #1
0
ファイル: Starter.php プロジェクト: mazelab/phantomjsstarter
 /**
  * Starts a new phantomjs process in background
  *
  * @throws \Symfony\Component\Process\Exception\RuntimeException
  */
 public function up()
 {
     $this->killAllRunning();
     $this->process = new Process('phantomjs --webdriver=' . $this->port . ' ' . $this->options);
     $process = $this->process;
     $output = new GenericEvent();
     $process->setTimeout(null);
     $process->start(function () use($process, $output) {
         $output->setArgument('output', $process->getIncrementalOutput());
     });
     $phantomjsOnline = false;
     $portScan = false;
     while (!$phantomjsOnline) {
         if ($output->hasArgument('output')) {
             $portScan = strpos($output->getArgument('output'), 'running on port ' . $this->port);
         }
         if ($portScan) {
             echo $output->getArgument('output');
         }
         $phantomjsOnline = $process->isStarted() && $process->isRunning() && $portScan;
         if ($process->isTerminated()) {
             throw new RuntimeException('Phantomjs could not been started with webdriver on port ' . $this->port);
         }
     }
 }
コード例 #2
0
 public function testHasArgument()
 {
     $this->assertTrue($this->event->hasArgument('name'));
     $this->assertFalse($this->event->hasArgument('nameNotExist'));
 }