Esempio n. 1
0
 public function testTestMode()
 {
     $checkUf = escapeshellarg('return CIVICRM_UF;');
     $p1 = Process::runOk($this->cv("ev {$checkUf}"));
     $this->assertRegExp('/(Drupal|Joomla|WordPress|Backdrop)/i', $p1->getOutput());
     $p1 = Process::runOk($this->cv("ev -t {$checkUf}"));
     $this->assertRegExp('/UnitTests/i', $p1->getOutput());
 }
Esempio n. 2
0
 public function testBootTest()
 {
     $phpBoot = Process::runOk($this->cv("php:boot --test"));
     $this->assertRegExp(';CIVICRM_SETTINGS_PATH;', $phpBoot->getOutput());
     $helloPhp = escapeshellarg($phpBoot->getOutput() . 'echo CIVICRM_UF;');
     $phpRun = Process::runOk(new \Symfony\Component\Process\Process("php -ddisplay_errors=1 -r {$helloPhp}"));
     $this->assertRegExp('/UnitTests/i', $phpRun->getOutput());
 }
Esempio n. 3
0
 public function testRunOk_fail()
 {
     try {
         ProcessUtil::runOk(new \Symfony\Component\Process\Process("echo tragedy befell the software > /dev/stderr; exit 1"));
         $this->fail("Failed to generate expected exception");
     } catch (\Civi\Cv\Exception\ProcessErrorException $e) {
         $this->assertEquals("tragedy befell the software", trim($e->getProcess()->getErrorOutput()));
     }
 }
Esempio n. 4
0
 public function testApiPipe()
 {
     $input = escapeshellarg(json_encode(array('options' => array('limit' => 1))));
     $p = Process::runOk(new \Symfony\Component\Process\Process("echo {$input} | {$this->cv} api Contact.get --in=json"));
     $data = json_decode($p->getOutput(), 1);
     $this->assertTrue(!empty($data['values']));
     $this->assertEquals(1, count($data['values']));
     foreach ($data['values'] as $row) {
         $this->assertTrue(!empty($row['display_name']));
     }
 }
Esempio n. 5
0
 public function testUrl()
 {
     $url = escapeshellarg('civicrm/a/#/mailing/new?angularDebug=1&foo=bar');
     $p = Process::runOk($this->cv("url {$url}"));
     $fullUrl = json_decode($p->getOutput());
     $this->assertNotEmpty(parse_url($fullUrl, PHP_URL_HOST));
     $this->assertNotEmpty(parse_url($fullUrl, PHP_URL_SCHEME));
     $this->assertRegExp(':angularDebug=1:', $fullUrl);
     $this->assertRegExp(':foo=bar:', $fullUrl);
     $this->assertRegExp(':/mailing/new:', $fullUrl);
 }
Esempio n. 6
0
 protected function execute(InputInterface $input, OutputInterface $output)
 {
     $this->boot($input, $output);
     $path = parse_url($input->getArgument('path'), PHP_URL_PATH);
     $query = parse_url($input->getArgument('path'), PHP_URL_QUERY);
     $fragment = parse_url($input->getArgument('path'), PHP_URL_FRAGMENT);
     $value = \CRM_Utils_System::url($path, $query, !$input->getOption('relative'), $fragment, FALSE, (bool) $input->getOption('frontend'), (bool) (!$input->getOption('frontend')));
     if ($input->getOption('open')) {
         $cmd = $this->pickCommand();
         if (!$cmd) {
             throw new \RuntimeException("Failed to locate 'xdg-open' or 'open'. Open not supported on this system.");
         }
         $escaped = escapeshellarg($value);
         Process::runOk(new \Symfony\Component\Process\Process("{$cmd} {$escaped}"));
     }
     $this->sendResult($input, $output, $value);
 }
Esempio n. 7
0
 public function testPhpScript()
 {
     $helloPhp = escapeshellarg(__DIR__ . '/hello-world.php');
     $p = Process::runOk($this->cv("php:script {$helloPhp}"));
     $this->assertRegExp('/^version [0-9a-z\\.]+$/', $p->getOutput());
 }