From ff74b2f0c585d91aaae8b3b364e895a371e42704 Mon Sep 17 00:00:00 2001 From: Dmitry Khomutov Date: Sat, 21 Jan 2017 11:18:31 +0700 Subject: [PATCH] Codeception fixes --- src/PHPCensor/Model/Build.php | 2 +- src/PHPCensor/Plugin/Codeception.php | 23 +++++++++++++++++------ src/PHPCensor/Plugin/Util/Executor.php | 4 +++- 3 files changed, 21 insertions(+), 8 deletions(-) diff --git a/src/PHPCensor/Model/Build.php b/src/PHPCensor/Model/Build.php index 888e8308..fc553d59 100644 --- a/src/PHPCensor/Model/Build.php +++ b/src/PHPCensor/Model/Build.php @@ -156,7 +156,7 @@ class Build extends BuildBase $reflectedPlugin = new \ReflectionClass($className); - if (!$reflectedPlugin->implementsInterface('\PHPCensor\ZeroConfigPlugin')) { + if (!$reflectedPlugin->implementsInterface('\PHPCensor\ZeroConfigPluginInterface')) { continue; } diff --git a/src/PHPCensor/Plugin/Codeception.php b/src/PHPCensor/Plugin/Codeception.php index f6f0d415..a0fec023 100644 --- a/src/PHPCensor/Plugin/Codeception.php +++ b/src/PHPCensor/Plugin/Codeception.php @@ -38,9 +38,12 @@ class Codeception extends Plugin implements ZeroConfigPluginInterface protected $ymlConfigFile; /** - * @var string $path The path to the codeception tests folder. + * @var array $path The path to the codeception tests folder. */ - protected $path; + protected $path = [ + 'tests/_output', + 'tests/_log', + ]; /** * @return string @@ -57,8 +60,6 @@ class Codeception extends Plugin implements ZeroConfigPluginInterface { parent::__construct($builder, $build, $options); - $this->path = 'tests' . DIRECTORY_SEPARATOR . '_output' . DIRECTORY_SEPARATOR; - if (empty($options['config'])) { $this->ymlConfigFile = self::findConfigFile($this->builder->buildPath); } else { @@ -140,11 +141,21 @@ class Codeception extends Plugin implements ZeroConfigPluginInterface $yaml = file_get_contents($configPath); $config = (array)$parser->parse($yaml); + $outputPath = null; if ($config && isset($config['paths']['log'])) { - $this->path = $config['paths']['log'] . DIRECTORY_SEPARATOR; + $outputPath = $this->builder->buildPath . $config['paths']['log'] . '/'; + } + + if (!file_exists($outputPath . 'report.xml')) { + foreach ($this->path as $path) { + $outputPath = $this->builder->buildPath . $path . '/'; + if (file_exists($outputPath . 'report.xml')) { + break; + } + } } - $xml = file_get_contents($this->builder->buildPath . $this->path . 'report.xml', false); + $xml = file_get_contents($outputPath . 'report.xml', false); $parser = new Parser($this->builder, $xml); $output = $parser->parse(); diff --git a/src/PHPCensor/Plugin/Util/Executor.php b/src/PHPCensor/Plugin/Util/Executor.php index 884ba313..8af07545 100644 --- a/src/PHPCensor/Plugin/Util/Executor.php +++ b/src/PHPCensor/Plugin/Util/Executor.php @@ -43,8 +43,10 @@ class Executor /** * Execute a the appropriate set of plugins for a given build stage. - * @param array $config PHPCI configuration + * + * @param array $config PHPCI configuration * @param string $stage + * * @return bool */ public function executePlugins(&$config, $stage)