#!/usr/bin/env php
<?php
/*
 * This file is part of PHPUnit.
 *
 * (c) Sebastian Bergmann <sebastian@phpunit.de>
 *
 * For the full copyright and license information, please view the LICENSE
 * file that was distributed with this source code.
 */

if (version_compare('5.3.3', PHP_VERSION, '>')) {
    fwrite(
        STDERR,
        'This version of PHPUnit requires PHP 5.3.3; using the latest version of PHP is highly recommended.' . PHP_EOL
    );

    die(1);
}

if (!ini_get('date.timezone')) {
    ini_set('date.timezone', 'UTC');
}

// Ensure correct include_path for RHSCL
$inc = get_include_path();
$dirs = explode(':', $inc);
if (!in_array('/usr/share/php', $dirs)) {
    $dirs[] = '/usr/share/php';
    set_include_path(implode(':', $dirs));
}
unset ($inc, $dirs);

// Libraries PATH
if (file_exists('./vendor/phpunit/phpunit/phpunit') && file_exists('./vendor/autoload.php')) {
  echo "\n==== Redirecting to composer installed version in vendor/phpunit ====\n\n";
  define ('PHPUNIT_COMPOSER_INSTALL', realpath('./vendor/autoload.php'));
} else {
  define ('PHPUNIT_COMPOSER_INSTALL', stream_resolve_include_path('PHPUnit/Autoload.php'));
}

require PHPUNIT_COMPOSER_INSTALL;

PHPUnit_TextUI_Command::main();
