From 413230f5fc310a999aa59dc04415b310879e11e4 Mon Sep 17 00:00:00 2001 From: Dmitry Khomutov Date: Sun, 8 Jan 2017 23:00:32 +0700 Subject: [PATCH] Fixes for Codeception plugin --- docs/en/plugins/codeception.md | 21 +-------------------- src/PHPCensor/Plugin/Codeception.php | 20 +++++++++----------- 2 files changed, 10 insertions(+), 31 deletions(-) diff --git a/docs/en/plugins/codeception.md b/docs/en/plugins/codeception.md index 401950d3..d037f5f5 100644 --- a/docs/en/plugins/codeception.md +++ b/docs/en/plugins/codeception.md @@ -12,8 +12,6 @@ Configuration * **args** - Optional - The string of arguments to be passed to the run command.**Important**, due to the assumption made on line 132 regarding the value of `--xml` being the next argument which will not be correct if the user provides arguments using this config param, you must specify `report.xml` before any user input arguments to satisfy the report processing on line 146. -* **path** - Optional - The path from the root of your project to the root of the codeception _output directory - #### Default values - config @@ -24,27 +22,10 @@ Configuration - args - Empty string -- path - - `tests/_output/` - ### Examples -#### Example on running codeception with default settings (when tests are in tests/ directory): - ``` codeception: config: "codeception.yml" - path: "tests/" + args: "--no-ansi --coverage-html" ``` - -#### Example usage against the Yii2 framework - -``` -codeception: - allow_failures: false - config: "tests/codeception.yml" - path: "tests/codeception/_output/" - args: "report.xml --no-ansi --coverage-html" -``` - -The path value will need to be changed if you have your tests directory somewhere other than in the root of the project. diff --git a/src/PHPCensor/Plugin/Codeception.php b/src/PHPCensor/Plugin/Codeception.php index 2d9bb310..f6f0d415 100644 --- a/src/PHPCensor/Plugin/Codeception.php +++ b/src/PHPCensor/Plugin/Codeception.php @@ -14,6 +14,7 @@ use PHPCensor\Helper\Lang; use PHPCensor\Model\Build; use PHPCensor\Plugin\Util\TestResultParsers\Codeception as Parser; use PHPCensor\Plugin; +use Symfony\Component\Yaml\Parser as YamlParser; use PHPCensor\ZeroConfigPluginInterface; use Psr\Log\LogLevel; @@ -66,9 +67,6 @@ class Codeception extends Plugin implements ZeroConfigPluginInterface if (isset($options['args'])) { $this->args = (string) $options['args']; } - if (isset($options['path'])) { - $this->path = $options['path']; - } } /** @@ -121,8 +119,6 @@ class Codeception extends Plugin implements ZeroConfigPluginInterface */ protected function runConfigFile($configPath) { - $this->builder->logExecOutput(false); - $codeception = $this->builder->findBinary('codecept'); if (!$codeception) { @@ -140,12 +136,15 @@ class Codeception extends Plugin implements ZeroConfigPluginInterface $configPath = $this->builder->buildPath . $configPath; $success = $this->builder->executeCommand($cmd, $this->builder->buildPath, $configPath); - $this->builder->log( - 'Codeception XML path: '. $this->builder->buildPath . $this->path . 'report.xml', - LogLevel::DEBUG - ); + $parser = new YamlParser(); + $yaml = file_get_contents($configPath); + $config = (array)$parser->parse($yaml); - $xml = file_get_contents($this->builder->buildPath . $this->path . 'report.xml', false); + if ($config && isset($config['paths']['log'])) { + $this->path = $config['paths']['log'] . DIRECTORY_SEPARATOR; + } + + $xml = file_get_contents($this->builder->buildPath . $this->path . 'report.xml', false); $parser = new Parser($this->builder, $xml); $output = $parser->parse(); @@ -158,7 +157,6 @@ class Codeception extends Plugin implements ZeroConfigPluginInterface $this->build->storeMeta('codeception-meta', $meta); $this->build->storeMeta('codeception-data', $output); $this->build->storeMeta('codeception-errors', $parser->getTotalFailures()); - $this->builder->logExecOutput(true); return $success; }