Exemplo n.º 1
0
<?php

$usage = "Test runner\nUsage: test/run.php [--filter=<expr>]\n           [--coverage-html=<outpath>] \n           [--exclude-group=<group>]\n           [--group=<group>]\n           [--throw-on-error]\n\nThis runner captures warnings in a different way to PHPUnit. If you want\nto see stack traces for debugging when PHP errors, warnings, etc are thrown,\npass --throw-on-error.\n";
$basePath = __DIR__;
$testPath = __DIR__ . "/test";
require_once "{$basePath}/vendor/autoload.php";
require_once "{$testPath}/config.php";
error_reporting(E_ALL);
autoload_namespace('Defile\\Test', $testPath . '/lib', ['prepend' => true]);
// if it gets too tricky to find your bug, enable this:
// \Defile\StreamWrapper::$logHandle = fopen("php://stdout", "w");
stream_chunk_ensure_quirk();
$options = array('coverage-html' => null, 'filter' => null, 'exclude-group' => null, 'group' => null);
$options = array_merge($options, getopt('q:', array('help', 'filter:', 'coverage-html:', 'exclude-group:', 'group:', 'throw-on-error')) ?: []);
$help = array_key_exists('help', $options);
if ($help) {
    echo $usage;
    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);
Exemplo n.º 2
0
<?php

date_default_timezone_set('Australia/Melbourne');
require_once __DIR__ . '/../vendor/autoload.php';
require_once __DIR__ . '/../doc/demo/model.php';
require_once __DIR__ . '/../doc/demo/ar.php';
autoload_namespace('Amiss\\Test', __DIR__ . '/lib');
function autoload_namespace($prefix, $path, $options = array())
{
    $defaults = ['prepend' => false, 'suffix' => '.php', 'stripPrefix' => true, 'separator' => '\\'];
    $options = array_merge($defaults, $options);
    $prefix = trim($prefix, $options['separator']);
    spl_autoload_register(function ($class) use($prefix, $path, $options) {
        static $prefixLen = null;
        if ($prefixLen === null) {
            $prefixLen = strlen($prefix);
        }
        if (strpos($class, $prefix . $options['separator']) === 0 || $class == $prefix) {
            $toSplit = $options['stripPrefix'] ? substr($class, $prefixLen) : $class;
            $file = str_replace('../', '', $path . '/' . str_replace($options['separator'], '/', $toSplit)) . $options['suffix'];
            if (file_exists($file)) {
                require $file;
            }
        }
    }, null, $options['prepend']);
}
Exemplo n.º 3
0
<?php

require __DIR__ . '/../vendor/autoload.php';
if (!defined('FULFIL_BASE_PATH')) {
    define('FULFIL_BASE_PATH', realpath(__DIR__ . '/../'));
}
autoload_namespace('Fulfil\\Test', __DIR__ . '/lib');
function autoload_namespace($prefix, $path, $options = array())
{
    $defaults = array('prepend' => false, 'suffix' => '.php', 'stripPrefix' => true, 'separator' => '\\');
    $options = array_merge($defaults, $options);
    $prefix = trim($prefix, $options['separator']);
    spl_autoload_register(function ($class) use($prefix, $path, $options) {
        static $prefixLen = null;
        if ($prefixLen === null) {
            $prefixLen = strlen($prefix);
        }
        if (strpos($class, $prefix . $options['separator']) === 0 || $class == $prefix) {
            $toSplit = $options['stripPrefix'] ? substr($class, $prefixLen) : $class;
            $file = str_replace('../', '', $path . '/' . str_replace($options['separator'], '/', $toSplit)) . $options['suffix'];
            if (file_exists($file)) {
                require $file;
            }
        }
    }, null, $options['prepend']);
}