Skip to content

Instantly share code, notes, and snippets.

@alexsandro-xpt
Last active August 29, 2015 13:56
Show Gist options
  • Save alexsandro-xpt/9252718 to your computer and use it in GitHub Desktop.
Save alexsandro-xpt/9252718 to your computer and use it in GitHub Desktop.
Configurações para o PHPUnit

tests\phpunit.xml

<phpunit backupGlobals="false"
         backupStaticAttributes="false"
         bootstrap="../public/bootstrap.php"
         cacheTokens="true"
         colors="false"
         convertErrorsToExceptions="true"
         convertNoticesToExceptions="true"
         convertWarningsToExceptions="true"
         processIsolation="false"
         stopOnFailure="false"
         syntaxCheck="false"
         verbose="false">
    <filter>
        <whitelist>
            <directory>../src/Projeto</directory>
        </whitelist>
    </filter>
</phpunit>

../public/bootstrap.php

<?php

ini_set('display_errors', 1);
error_reporting(E_ALL | E_STRICT);
date_default_timezone_set('America/Sao_Paulo');

define('DS', DIRECTORY_SEPARATOR);
define('APP_ROOT', realpath(__DIR__ . DS . '..'));

$composer_autoload = APP_ROOT . DS . 'vendor' . DS . 'autoload.php';
if (!@include($composer_autoload)) {

    /* Include path */
    set_include_path(implode(PATH_SEPARATOR, array(
        __DIR__ . '/../src',
        get_include_path(),
    )));

    /* PEAR autoloader */
    spl_autoload_register(
        function($className) {
            $filename = strtr($className, '\\', DIRECTORY_SEPARATOR) . '.php';
            foreach (explode(PATH_SEPARATOR, get_include_path()) as $path) {
                $path .= DIRECTORY_SEPARATOR . $filename;
                if (is_file($path)) {
                    require_once $path;
                    return true;
                }
            }
            return false;
        }
    );
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment