コード例 #1
0
ファイル: runtests.php プロジェクト: gtbear/flexihash
<?php

/**
 * Basic command line test runner for Flexihash.
 *
 * @author Paul Annesley
 * @package Flexihash
 * @licence http://www.opensource.org/licenses/mit-license.php
 */
error_reporting(E_ALL);
ini_set('display_errors', true);
require dirname(__FILE__) . '/../include/init.php';
$basedir = realpath(dirname(__FILE__) . '/..');
flexihash_unshift_include_path(array("{$basedir}/lib/simpletest", "{$basedir}/tests"));
if (in_array('--help', $argv)) {
    echo <<<EOM

CLI test runner.

Available options:

  --testfile <path>  Only run the specified test file.
  --with-benchmark   Run benchmarks.
  --help             This documentation.


EOM;
    exit(0);
}
require_once 'simpletest/unit_tester.php';
require_once 'simpletest/reporter.php';
コード例 #2
0
ファイル: init.php プロジェクト: gtbear/flexihash
 * @author Paul Annesley
 * @package Flexihash
 * @licence http://www.opensource.org/licenses/mit-license.php
 */
/**
 * @param mixed $items Path or paths as string or array
 */
function flexihash_unshift_include_path($items)
{
    $elements = explode(PATH_SEPARATOR, get_include_path());
    if (is_array($items)) {
        set_include_path(implode(PATH_SEPARATOR, array_merge($items, $elements)));
    } else {
        array_unshift($elements, $items);
        set_include_path(implode(PATH_SEPARATOR, $elements));
    }
}
/**
 * SPL autoload function, loads a flexihash class file based on the class name.
 *
 * @param string
 */
function flexihash_autoload($className)
{
    if (preg_match('#^Flexihash#', $className)) {
        require_once preg_replace('#_#', '/', $className) . '.php';
    }
}
$basedir = realpath(dirname(__FILE__) . '/..');
flexihash_unshift_include_path(array("{$basedir}/classes", "{$basedir}/lib"));
spl_autoload_register('flexihash_autoload');