Beispiel #1
0
 /**
  * @param Channel     $channel
  * @param mixed       $inputLine
  * @param int|null    $processCounter
  * @param string|null $template
  * @param string|null $cwd
  *
  * @return Process
  */
 public function create(Channel $channel, $inputLine, $processCounter, $template = null, $cwd = null)
 {
     $environment = new ProcessEnvironment($channel, $inputLine, $processCounter);
     $engine = $this->templateEngine;
     $commandLine = $engine($environment, (string) $template);
     if (is_string($commandLine)) {
         $commandLine = CommandLine::fromString($commandLine);
     }
     return $this->createProcess($commandLine, $environment, $cwd);
 }
Beispiel #2
0
 /**
  * @test
  */
 public function onChannelWaitABeforeCommandLineShouldExecuteANewProcess()
 {
     $process = $this->getMockBuilder('\\Liuggio\\Spawn\\Process\\Process')->disableOriginalConstructor()->getMock();
     $channel = Channel::createAWaiting(3, 5);
     $queue = $this->getMock('\\Liuggio\\Spawn\\Queue\\QueueInterface');
     $queue->expects($this->once())->method('dequeue')->willReturn(10);
     $processFactory = $this->getMock('\\Liuggio\\Spawn\\Process\\ProcessFactory');
     $processFactory->expects($this->once())->method('create')->with($this->equalTo($channel))->willReturn($process);
     $ed = $this->getMock('\\Symfony\\Component\\EventDispatcher\\EventDispatcherInterface');
     $consumer = new ConsumerListener($queue, $ed, $processFactory, CommandLine::fromString("echo 'a'"));
     $consumer->onChannelIsWaiting(new ChannelIsWaitingEvent($channel));
 }