Beispiel #1
0
 /**
  * Kills commands, which syntax is similar to this command
  */
 public function killSimilar()
 {
     if (OS::WIN === OS::getCurrentOs()) {
         throw new OsNotSupportedExeception();
     }
     $command = Command::create()->app('ps')->arg('aux')->app('grep')->input('"' . $this->prepareForProcessLog($this->command->getRaw()) . '"')->xargsApp()->input('awk', 'kill')->app1()->input('print $2')->exec();
 }
Beispiel #2
0
 public function testKillSimilar()
 {
     $async = Command::create()->phpApp()->arg('r')->input('\'sleep(10);\'')->async()->exec();
     $this->assertTrue($async->isSimilarRunning());
     $async->killSimilar();
     $this->assertFalse($async->isSimilarRunning());
 }
Beispiel #3
0
 public function testCmdActionAndArgs()
 {
     $cmd = 'controller';
     $action = 'action';
     $arg1 = 'begin';
     $arg2 = 'end';
     $expected = sprintf('php console.php %s %s --%s=1 --%s=11000000', $cmd, $action, $arg1, $arg2);
     $result = Command::create()->yiiApp()->cmd($cmd)->action($action)->arg($arg1, '1', '--')->arg($arg2, '11000000', '--')->getRaw();
     $this->assertEquals($expected, $result);
 }
Beispiel #4
0
 /**
  * Test the getRaw method by giving an app name, an argument and an input
  */
 public function testGetRawWithArgsAndInput()
 {
     $expected = 'echo -e Hallo Welt';
     $result = Command::create()->app('echo')->arg('e')->input('Hallo Welt')->getRaw();
     $this->assertEquals($expected, $result);
 }