Ejemplo n.º 1
0
 public function execute()
 {
     if (empty($this->command)) {
         $this->phpci->logFailure('Configuration command not found.');
         return false;
     }
     if (empty($this->directory)) {
         $this->phpci->logFailure('Configuration directory not found.');
         return false;
     }
     $this->phpci->logExecOutput(false);
     $cmd = 'cd ' . $this->directory . '; ' . $this->command;
     $this->phpci->executeCommand($cmd);
     $tapString = $this->phpci->getLastOutput();
     if ($this->data_offset) {
         $tapString = implode("\n", array_slice(explode("\n", $tapString), $this->data_offset));
     }
     $tapString = mb_convert_encoding($tapString, "UTF-8", "ISO-8859-1");
     $tapString = 'TAP version 13' . "\n" . $tapString;
     try {
         $tapParser = new TapParser($tapString);
         $output = $tapParser->parse();
     } catch (\Exception $ex) {
         $this->phpci->logFailure($tapString);
         throw $ex;
     }
     $failures = $tapParser->getTotalFailures();
     $success = $failures === 0;
     $this->build->storeMeta('mocha-errors', $failures);
     $this->build->storeMeta('mocha-data', $output);
     $this->phpci->logExecOutput(true);
     return $success;
 }
Ejemplo n.º 2
0
    public function testSkipped()
    {
        $content = <<<TAP
TAP version 13
ok 1 - SomeTest::testAnother
ok 2 - # SKIP
1..2
TAP;
        $parser = new TapParser($content);
        $result = $parser->parse();
        $this->assertEquals(array(array('pass' => true, 'suite' => 'SomeTest', 'test' => 'testAnother'), array('message' => 'SKIP')), $result);
        $this->assertEquals(0, $parser->getTotalFailures());
    }
Ejemplo n.º 3
0
 /**
  * {@inheritDoc}
  */
 public function execute()
 {
     $success = true;
     $this->phpci->logExecOutput(false);
     // Run any config files first. This can be either a single value or an array
     if ($this->configFile !== null) {
         $success &= $this->runConfigFile($this->configFile);
     }
     $tapString = file_get_contents($this->phpci->buildPath . $this->logPath . DIRECTORY_SEPARATOR . 'report.tap.log');
     try {
         $tapParser = new TapParser($tapString);
         $output = $tapParser->parse();
     } catch (\Exception $ex) {
         $this->phpci->logFailure($tapString);
         throw $ex;
     }
     $failures = $tapParser->getTotalFailures();
     $this->build->storeMeta('codeception-errors', $failures);
     $this->build->storeMeta('codeception-data', $output);
     $this->phpci->logExecOutput(true);
     return $success;
 }
Ejemplo n.º 4
0
 /**
  * {@inheritdoc}
  */
 public function execute()
 {
     $curdir = getcwd();
     chdir($this->phpci->buildPath);
     if (!is_file($this->configFile)) {
         $this->phpci->logFailure(sprintf('The Atoum config file "%s" is missing.', $this->configFile));
         chdir($curdir);
         return false;
     }
     $this->phpci->logExecOutput(false);
     $status = $this->phpci->executeCommand('php %s -c %s -ft -utr', $this->executable, $this->configFile);
     $this->phpci->logExecOutput(true);
     try {
         $parser = new TapParser(mb_convert_encoding('TAP version 13' . PHP_EOL . $this->phpci->getLastOutput(), 'UTF-8', 'ISO-8859-1'));
         $data = $parser->parse();
         $this->reportErrors($data);
     } catch (\Exception $exception) {
         $status = false;
         $this->phpci->logFailure('Impossible to parse the Atoum output.', $exception);
     }
     chdir($curdir);
     return $status;
 }
Ejemplo n.º 5
0
 /**
  * Runs PHP Unit tests in a specified directory, optionally using specified config file(s).
  */
 public function execute()
 {
     if (empty($this->xmlConfigFile) && empty($this->directory)) {
         $this->phpci->logFailure('Neither configuration file nor test directory found.');
         return false;
     }
     $success = true;
     $this->phpci->logExecOutput(false);
     // Run any config files first. This can be either a single value or an array.
     if ($this->xmlConfigFile !== null) {
         $success &= $this->runConfigFile($this->xmlConfigFile);
     }
     // Run any dirs next. Again this can be either a single value or an array.
     if ($this->directory !== null) {
         $success &= $this->runDir($this->directory);
     }
     $tapString = $this->phpci->getLastOutput();
     $tapString = mb_convert_encoding($tapString, "UTF-8", "ISO-8859-1");
     try {
         $tapParser = new TapParser($tapString);
         $output = $tapParser->parse();
     } catch (\Exception $ex) {
         $this->phpci->logFailure($tapString);
         throw $ex;
     }
     $failures = $tapParser->getTotalFailures();
     $this->build->storeMeta('phpunit-errors', $failures);
     $this->build->storeMeta('phpunit-data', $output);
     $this->phpci->logExecOutput(true);
     return $success;
 }
Ejemplo n.º 6
0
    public function testCodeception()
    {
        $content = <<<TAP
TAP version 13
ok 1 - try to access the dashboard as a guest (Auth/GuestAccessDashboardAndRedirectCept)
ok 2 - see the login page (Auth/SeeLoginCept)
ok 3 - click forgot password and see the email form (Auth/SeeLoginForgotPasswordCept)
ok 4 - see powered by runmybusiness branding (Auth/ShouldSeePoweredByBrandingCept)
ok 5 - submit invalid credentials (Auth/SubmitLoginAndFailCept)
ok 6 - submit valid credentials and see the dashboard (Auth/SubmitLoginAndSucceedCept)
1..6
TAP;
        $parser = new TapParser($content);
        $result = $parser->parse();
        $this->assertEquals(array(array('pass' => true, 'severity' => 'success', 'message' => 'try to access the dashboard as a guest (Auth/GuestAccessDashboardAndRedirectCept)'), array('pass' => true, 'severity' => 'success', 'message' => 'see the login page (Auth/SeeLoginCept)'), array('pass' => true, 'severity' => 'success', 'message' => 'click forgot password and see the email form (Auth/SeeLoginForgotPasswordCept)'), array('pass' => true, 'severity' => 'success', 'message' => 'see powered by runmybusiness branding (Auth/ShouldSeePoweredByBrandingCept)'), array('pass' => true, 'severity' => 'success', 'message' => 'submit invalid credentials (Auth/SubmitLoginAndFailCept)'), array('pass' => true, 'severity' => 'success', 'message' => 'submit valid credentials and see the dashboard (Auth/SubmitLoginAndSucceedCept)')), $result);
        $this->assertEquals(0, $parser->getTotalFailures());
    }
Ejemplo n.º 7
0
 /**
  * Runs PHP Unit tests in a specified directory, optionally using specified config file(s).
  */
 public function execute()
 {
     $success = true;
     $this->phpci->logExecOutput(false);
     // Run any config files first. This can be either a single value or an array.
     if ($this->xmlConfigFile !== null) {
         $success &= $this->runConfigFile($this->xmlConfigFile);
     }
     // Run any dirs next. Again this can be either a single value or an array.
     if ($this->directory !== null) {
         $success &= $this->runDir();
     }
     $tapString = $this->phpci->getLastOutput();
     try {
         $tapParser = new TapParser($tapString);
         $output = $tapParser->parse();
     } catch (\Exception $ex) {
         $this->phpci->logFailure($tapString);
         throw $ex;
     }
     $failures = $tapParser->getTotalFailures();
     $this->build->storeMeta('phpunit-errors', $failures);
     $this->build->storeMeta('phpunit-data', $output);
     $this->phpci->logExecOutput(true);
     return $success;
 }