Created
August 8, 2013 15:09
-
-
Save dongilbert/6185448 to your computer and use it in GitHub Desktop.
Codeception plugin for PHPCI
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
/** | |
* PHPCI - Continuous Integration for PHP | |
* | |
* @copyright Copyright 2013, Block 8 Limited. | |
* @license https://github.com/Block8/PHPCI/blob/master/LICENSE.md | |
* @link http://www.phptesting.org/ | |
*/ | |
namespace PHPCI\Plugin; | |
/** | |
* Codeception Plugin - Enables full acceptance, unit, and functional testing. | |
* @author Don Gilbert <[email protected]> | |
* @package PHPCI | |
* @subpackage Plugins | |
*/ | |
class CodeCeption implements \PHPCI\Plugin | |
{ | |
protected $args; | |
protected $phpci; | |
/** | |
* @var string|string[] $xmlConfigFile The path (or array of paths) of an xml config for PHPUnit | |
*/ | |
protected $xmlConfigFile; | |
public function __construct(\PHPCI\Builder $phpci, array $options = array()) | |
{ | |
$this->phpci = $phpci; | |
if (isset($options['config'])) { | |
$this->xmlConfigFile = $options['config']; | |
} | |
if (isset($options['args'])) { | |
$this->args = $options['args']; | |
} | |
} | |
/** | |
* Runs Codeception tests, optionally using specified config file(s). | |
*/ | |
public function execute() | |
{ | |
$success = true; | |
// Run any config files first. This can be either a single value or an array. | |
if ($this->xmlConfigFile !== null) { | |
$success &= $this->runConfigFile($this->xmlConfigFile); | |
} | |
return $success; | |
} | |
protected function runConfigFile($configPath) | |
{ | |
if (is_array($configPath)) { | |
return $this->recurseArg($configPath, array($this, "runConfigFile")); | |
} else { | |
$cmd = PHPCI_BIN_DIR . 'codecept run -c "%s"'; | |
$success = $this->phpci->executeCommand($cmd, $this->phpci->buildPath . $configPath); | |
return $success; | |
} | |
} | |
protected function recurseArg($array, $callable) | |
{ | |
$success = true; | |
foreach ($array as $subItem) { | |
$success &= call_user_func($callable, $subItem); | |
} | |
return $success; | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment