Commit 7eed1370 authored by Bertrand Gauthier's avatar Bertrand Gauthier
Browse files

Réorganisation config phpunit

parent 3f460c17
Loading
Loading
Loading
Loading

phpunit.xml

0 → 100644
+26 −0
Original line number Diff line number Diff line
<?xml version="1.0" encoding="UTF-8"?>

<phpunit bootstrap="vendor/autoload.php" colors="true">
    <testsuites>
        <testsuite name="unit">
            <directory>./tests/UnicaenAuthTest</directory>
        </testsuite>
    </testsuites>

    <filter>
        <whitelist processUncoveredFilesFromWhitelist="true">
            <directory suffix=".php">./src</directory>
        </whitelist>
    </filter>

    <!--<php>-->
        <!--&lt;!&ndash; Integration Test Variables &ndash;&gt;-->
        <!--<const name="HOST" value="localhost"/>-->
        <!--<const name="PORT" value="4444"/>-->
        <!--<const name="BROWSER_URL" value="http://localhost/snortlog/"/> &lt;!&ndash; '/' requis à la fin! &ndash;&gt;-->
        <!--<const name="CAS_URL" value="https://cas.unicaen.fr/"/> &lt;!&ndash; '/' requis à la fin! &ndash;&gt;-->
        <!--<const name="USERNAME" value="21009539"/>-->
        <!--<const name="PASSWORD" value="UCBN2010"/>-->
    <!--</php>-->

</phpunit>
 No newline at end of file

tests/Bootstrap.php

deleted100644 → 0
+0 −88
Original line number Diff line number Diff line
<?php
namespace UnicaenAppTest;

use Zend\Loader\AutoloaderFactory;
use Zend\Mvc\Service\ServiceManagerConfig;
use Zend\ServiceManager\ServiceManager;
use RuntimeException;

error_reporting(E_ALL | E_STRICT);
chdir(__DIR__);

/**
 * Test bootstrap, for setting up autoloading
 */
class Bootstrap
{
    protected static $serviceManager;

    public static function init()
    {
        $zf2ModulePaths = [dirname(dirname(__DIR__))];
        if (($path = static::findParentPath('vendor'))) {
            $zf2ModulePaths[] = $path;
        }
        if (($path = static::findParentPath('module')) !== $zf2ModulePaths[0]) {
            $zf2ModulePaths[] = $path;
        }
        $zf2ModulePaths[] = __DIR__;

        static::initAutoloader();

        static::$serviceManager = new ServiceManager(new ServiceManagerConfig());
    }

    public static function getServiceManager()
    {
        return static::$serviceManager;
    }

    protected static function initAutoloader()
    {
        $vendorPath = static::findParentPath('vendor');

        if (is_readable($vendorPath . '/autoload.php')) {
            include $vendorPath . '/autoload.php';
            return;
        }

        $zf2Path = getenv('ZF2_PATH');
        if (!$zf2Path) {
            if (defined('ZF2_PATH')) {
                $zf2Path = ZF2_PATH;
            } elseif (is_dir($vendorPath . '/ZF2/library')) {
                $zf2Path = $vendorPath . '/ZF2/library';
            } elseif (is_dir($vendorPath . '/zendframework/zendframework/library')) {
                $zf2Path = $vendorPath . '/zendframework/zendframework/library';
            }
        }

        if (!$zf2Path) {
            throw new RuntimeException('Unable to load ZF2. Run `php composer.phar install` or define a ZF2_PATH environment variable.');
        }

        include $zf2Path . '/Zend/Loader/AutoloaderFactory.php';
        AutoloaderFactory::factory([
            'Zend\Loader\StandardAutoloader' => [
                'autoregister_zf' => true,
                'namespaces' => [
                    __NAMESPACE__ => __DIR__ . '/' . __NAMESPACE__,
                ],
            ],
        ]);
    }

    protected static function findParentPath($path)
    {
        $dir = __DIR__;
        $previousDir = '.';
        while (!is_dir($dir . '/' . $path)) {
            $dir = dirname($dir);
            if ($previousDir === $dir) return false;
            $previousDir = $dir;
        }
        return $dir . '/' . $path;
    }
}

Bootstrap::init();
 No newline at end of file

tests/phpunit.xml

deleted100644 → 0
+0 −45
Original line number Diff line number Diff line
<?xml version="1.0" encoding="UTF-8"?>

<phpunit bootstrap="./Bootstrap.php" colors="true">
    <testsuites>
        <testsuite name="unit">
            <directory>./UnicaenAuthTest</directory>
        </testsuite>
        <testsuite name="functional">
            <directory>./functional</directory>
        </testsuite>
    </testsuites>

    <logging>
        <!--<log type="junit" target="/tmp/phpunit/logs/junit.xml" />-->
        <!--<log type="coverage-clover" target="/tmp/phpunit/logs/clover.xml" />-->
        <!--<log type="coverage-html" target="/tmp/phpunit/coverage" />-->
    </logging>
    
    <filter>
        <whitelist processUncoveredFilesFromWhitelist="true">
            <directory suffix=".php">../src</directory>
        </whitelist>
    </filter>

    <!--
    <groups>
        <exclude>
            <group>disable</group>
            <group>integration</group>
            <group>integration-sqlserver</group>
        </exclude>
    </groups>
    -->

    <php>
        <!-- Integration Test Variables -->
        <const name="HOST" value="localhost"/>
        <const name="PORT" value="4444"/>
        <const name="BROWSER_URL" value="http://localhost/snortlog/"/> <!-- '/' requis à la fin! -->
        <const name="CAS_URL" value="https://cas.unicaen.fr/"/> <!-- '/' requis à la fin! -->
        <const name="USERNAME" value="21009539"/>
        <const name="PASSWORD" value="UCBN2010"/>
    </php>

</phpunit>