Exemple #1
0
$usage = "Test runner\nUsage: test/run.php [--filter=<expr>]\n                    [--coverage-html=<outpath>]\n                    [--exclude-group=<group>]\n                    [--group=<group>]\n";
$basePath = __DIR__;
require $basePath . '/vendor/autoload.php';
org\bovigo\vfs\vfsStreamWrapper::register();
$options = array('coverage-html' => null, 'filter' => null, 'exclude-group' => null, 'group' => null, 'verbose' => false);
$options = array_merge($options, getopt('', array('help', 'filter:', 'coverage-html:', 'exclude-group:', 'group:', 'verbose')));
$help = array_key_exists('help', $options);
if ($help) {
    echo $usage;
    exit;
}
$config = array();
$groups = $options['group'] ? explode(',', $options['group']) : null;
$args = array('reportDirectory' => $options['coverage-html'], 'coverageHtml' => $options['coverage-html'], 'filter' => $options['filter'], 'excludeGroups' => explode(',', $options['exclude-group']), 'groups' => $groups, 'strict' => true, 'processIsolation' => false, 'backupGlobals' => false, 'backupStaticAttributes' => false, 'convertErrorsToExceptions' => true, 'convertNoticesToExceptions' => true, 'convertWarningsToExceptions' => true, 'addUncoveredFilesFromWhitelist' => true, 'processUncoveredFilesFromWhitelist' => true, 'verbose' => true);
$suite = new PHPUnit_Framework_TestSuite();
suite_add_dir($suite, $basePath . '/test/');
$filter = new PHP_CodeCoverage_Filter();
$filter->addDirectoryToWhitelist($basePath . '/lib/', '.php');
$runner = new PHPUnit_TextUI_TestRunner(null, $filter);
$runner->doRun($suite, $args);
function suite_add_dir($suite, $dir)
{
    $iter = new \RecursiveIteratorIterator(new \RecursiveDirectoryIterator($dir), \RecursiveIteratorIterator::LEAVES_ONLY);
    foreach ($iter as $item) {
        foreach (require_tests($item) as $class) {
            $suite->addTest(new PHPUnit_Framework_TestSuite($class));
        }
    }
}
function require_tests($file)
{
Exemple #2
0
    exit;
}
$throwOnError = array_key_exists('throw-on-error', $options);
define('THROW_ON_ERROR', $throwOnError);
$config = array();
$groups = $options['group'] ? explode(',', $options['group']) : null;
$args = array('reportDirectory' => $options['coverage-html'], 'filter' => $options['filter'], 'excludeGroups' => explode(',', $options['exclude-group']), 'groups' => $groups, 'strict' => true, 'processIsolation' => false, 'backupGlobals' => false, 'backupStaticAttributes' => false, 'convertErrorsToExceptions' => $throwOnError, 'convertNoticesToExceptions' => $throwOnError, 'convertWarningsToExceptions' => $throwOnError, 'addUncoveredFilesFromWhitelist' => true, 'processUncoveredFilesFromWhitelist' => true);
$masterSuite = new PHPUnit_Framework_TestSuite();
$suite = new PHPUnit_Framework_TestSuite();
suite_add_dir($suite, $testPath . '/lib/Unit/');
$masterSuite->addTest($suite);
$suite = new PHPUnit_Framework_TestSuite();
suite_add_dir($suite, $testPath . '/lib/FileSystem/');
$masterSuite->addTest($suite);
$suite = new PHPUnit_Framework_TestSuite();
suite_add_dir($suite, $testPath . '/lib/StreamWrapper/');
$masterSuite->addTest($suite);
$filter = new PHP_CodeCoverage_Filter();
$filter->addDirectoryToWhitelist($basePath . '/src/', '.php');
$runner = new PHPUnit_TextUI_TestRunner(null, $filter);
$runner->doRun($masterSuite, $args);
function suite_add_dir($suite, $dir)
{
    foreach (new \RecursiveIteratorIterator(new \RecursiveDirectoryIterator($dir), \RecursiveIteratorIterator::LEAVES_ONLY) as $item) {
        foreach (require_tests($item) as $class) {
            $suite->addTest(new PHPUnit_Framework_TestSuite($class));
        }
    }
}
function require_tests($file)
{
Exemple #3
0
    $suite->addTest($mysqlPersistentSuite);
}
if (in_array('pgsql', $with)) {
    if (!isset($config['pgsql'])) {
        throw new \Exception("Missing [pgsql] section in amisstestrc file");
    }
    $parts = [];
    if ($config['pgsql']['host']) {
        $parts[] = "host=" . $config['pgsql']['host'];
    }
    if ($config['pgsql']['port']) {
        $parts[] = "port=" . $config['pgsql']['port'];
    }
    $parts[] = "dbname=amiss_test";
    $pgsqlSuite = new \Amiss\Test\Helper\DatabaseSuite(array('engine' => 'pgsql', 'dsn' => "pgsql:" . implode(';', $parts), 'user' => $config['pgsql']['user'], 'password' => $config['pgsql']['password'], 'dbName' => 'amiss_test_' . time()));
    suite_add_dir($pgsqlSuite, $testPath . '/lib/Acceptance/');
    $suite->addTest($pgsqlSuite);
}
$filter = new PHP_CodeCoverage_Filter();
$filter->addDirectoryToWhitelist($basePath . '/src/', '.php');
$runner = new PHPUnit_TextUI_TestRunner(null, $filter);
$runner->doRun($suite, $args);
function suite_add_dir($suite, $dir)
{
    foreach (new \RecursiveIteratorIterator(new \RecursiveDirectoryIterator($dir), \RecursiveIteratorIterator::LEAVES_ONLY) as $item) {
        foreach (require_tests($item) as $class) {
            $suite->addTest(new PHPUnit_Framework_TestSuite($class));
        }
    }
}
function require_tests($file)