I have successfully used PHPSpec, but it is not actively developing now? This is great, but donβt think that Iβll go with a stalled project. In any case, I used the following setting to run tests from a web browser, maybe you will find something to help you configure it for the CLI.
PHPSpecConfiguration.php
$projectDir = realpath( dirname(__FILE__) . DIRECTORY_SEPARATOR . '..' ) . DIRECTORY_SEPARATOR; $simdal_root = $projectDir . 'library'; $phpspec_root = $projectDir . '..' . DIRECTORY_SEPARATOR . 'PHPSpec'; $mockery_root = $projectDir . '..' . DIRECTORY_SEPARATOR . 'Mockery'; $paths = array( 'SimDAL'=>$simdal_root, 'PHPSpec'=>$phpspec_root, 'Mockery'=>$mockery_root ); set_include_path( implode( PATH_SEPARATOR, $paths ) . PATH_SEPARATOR . get_include_path() ); require_once 'PHPSpec.php'; require_once 'Mockery/Framework.php'; class Custom_Autoload { public static function autoload($class) { //$path = dirname(dirname(__FILE__)); //include $path . '/' . str_replace('_', '/', $class) . '.php'; if (preg_match('/^([^ _]*)?(_[^ _]*)*$/', $class, $matches)) { include str_replace('_', '/', $class) . '.php'; return true; } return false; } } spl_autoload_register(array('Custom_Autoload', 'autoload'));
and then a file that runs everything: AllSpecs.php;
require_once 'PHPSpecTestConfiguration.php'; $options = new stdClass(); $options->recursive = true; $options->specdocs = true; $options->reporter = 'html'; PHPSpec_Runner::run($options);
I don't like CLI testing ... But it might help someone.
source share