phpci/PHPCI/Plugin/Behat.php

57 lines
1.2 KiB
PHP
Raw Normal View History

2013-10-08 11:26:11 +02:00
<?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;
2013-10-10 02:01:06 +02:00
use PHPCI\Builder;
use PHPCI\Model\Build;
2013-10-08 11:26:11 +02:00
/**
* Behat BDD Plugin
* @author Dan Cryer <dan@block8.co.uk>
* @package PHPCI
* @subpackage Plugins
*/
class Behat implements \PHPCI\Plugin
{
protected $phpci;
2013-10-10 02:01:06 +02:00
protected $features;
2013-10-08 11:26:11 +02:00
2013-10-10 02:01:06 +02:00
public function __construct(Builder $phpci, Build $build, array $options = array())
2013-10-08 11:26:11 +02:00
{
$this->phpci = $phpci;
2013-10-10 02:01:06 +02:00
$this->features = '';
if (!empty($options['features'])) {
$this->features = $options['features'];
}
2013-10-08 11:26:11 +02:00
}
/**
* Runs Behat tests.
*/
public function execute()
{
$curdir = getcwd();
chdir($this->phpci->buildPath);
2013-10-10 02:01:06 +02:00
$behat = $this->phpci->findBinary('behat');
2013-10-08 11:26:11 +02:00
2013-10-10 02:01:06 +02:00
if (!$behat) {
$this->phpci->logFailure('Could not find behat.');
2013-10-08 11:26:11 +02:00
return false;
}
2013-10-10 02:01:06 +02:00
$success = $this->phpci->executeCommand($behat . ' --no-time --format="failed" %s', $this->features);
2013-10-08 11:26:11 +02:00
chdir($curdir);
return $success;
}
}