Commit c5b78236 authored by Bertrand Gauthier's avatar Bertrand Gauthier
Browse files

Préparation pour tests unitaires.

parent 0bbc1de3
{
"name": "unicaen/unicaen-auth",
"description": "Module d'authentification pour les applis ZF2 de l'UCBN",
"type": "library",
"authors": [
"keywords": [
"framework",
"zf2",
"unicaen",
"ucbn"
],
"repositories": [
{
"name": "Bertrand GAUTHIER",
"email": "bertrand.gauthier@unicaen.fr"
"type": "vcs",
"url": "https://svn.unicaen.fr/svn/UnicaenApp"
}
],
"require": {
......@@ -15,13 +20,16 @@
"gorg/phpcas": "dev-master",
"bjyoungblood/bjy-authorize": ">=1.2"
},
"minimum-stability": "dev",
"require-dev": {
"phpunit/PHPUnit": "3.7.*"
},
"autoload": {
"psr-0": {
"UnicaenAuth": "src/"
"UnicaenAuth": "src/",
"UnicaenAuthTest": "tests/"
},
"classmap": [
"./Module.php"
]
}
}
}
\ No newline at end of file
<?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 = array(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(array(
'Zend\Loader\StandardAutoloader' => array(
'autoregister_zf' => true,
'namespaces' => array(
__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
<?php
// Application config
$appConfig = array();//include __DIR__ . '/../../../../../config/application.config.php';
// Test config
$testConfig = array(
'modules' => array(
'UnicaenAuth'
),
'module_listener_options' => array(
'config_glob_paths' => array(
__DIR__ . '/autoload/{,*.}{global,local}.php',
),
),
);
return \Zend\Stdlib\ArrayUtils::merge($appConfig, $testConfig);
<?php
return array(
// 'translator' => array(
// 'locale' => 'fr_FR',
// 'translation_file_patterns' => array(
// array(
// 'type' => 'getdtext',
// 'base_dir' => __DIR__ . '/../language',
// 'pattern' => '%s.mo',
// ),
// ),
// ),
'controllers' => array(
'invokables' => array(
'UnicaenAppTest\Controller\Plugin\TestAsset\Contact' => 'UnicaenAppTest\Controller\Plugin\TestAsset\ContactController',
),
),
);
<?php
/**
* UnicaenAuth Global Configuration
*
* If you have a ./config/autoload/ directory set up for your project, you can
* drop this config file in it and change the values as you wish.
*/
$settings = array(
/**
* Flag indiquant si l'utilisateur authenitifié avec succès via l'annuaire LDAP doit
* être enregistré/mis à jour dans la table des utilisateurs de l'appli.
*/
'save_ldap_user_in_database' => false,
/**
* Enable registration
* Allows users to register through the website.
* Accepted values: boolean true or false
*/
'enable_registration' => false,
);
/**
* You do not need to edit below this line
*/
return array(
'unicaen-auth' => $settings,
'zfcuser' => array(
$k='enable_registration' => isset($settings[$k]) ? $settings[$k] : false,
),
);
\ No newline at end of file
<?php
/**
* UnicaenAuth Configuration
*
* If you have a ./config/autoload/ directory set up for your project, you can
* drop this config file in it and change the values as you wish.
*/
$settings = array(
/**
* Paramètres de connexion au serveur CAS :
* - pour désactiver l'authentification CAS, le tableau 'cas' doit être vide.
* - pour l'activer, renseigner les paramètres.
*/
'cas' => array(
// 'connection' => array(
// 'default' => array(
// 'params' => array(
// 'hostname' => 'cas.unicaen.fr',
// 'port' => 443,
// 'version' => "2.0",
// 'uri' => "",
// 'debug' => false,
// ),
// ),
// ),
),
/**
* Identifiants de connexion LDAP autorisés à faire de l'usurpation d'identité.
* NB: à réserver exclusivement aux tests.
*/
// 'usurpation_allowed_usernames' => array(),
);
/**
* You do not need to edit below this line
*/
return array(
'unicaen-auth' => $settings,
);
\ No newline at end of file
<?php
/**
* UnicaenAuth Configuration
*
* If you have a ./config/autoload/ directory set up for your project, you can
* drop this config file in it and change the values as you wish.
*/
$settings = array(
/**
* Paramètres de connexion au serveur CAS :
* - pour désactiver l'authentification CAS, le tableau 'cas' doit être vide.
* - pour l'activer, renseigner les paramètres.
*/
'cas' => array(
// 'connection' => array(
// 'default' => array(
// 'params' => array(
// 'hostname' => 'cas.unicaen.fr',
// 'port' => 443,
// 'version' => "2.0",
// 'uri' => "",
// 'debug' => false,
// ),
// ),
// ),
),
/**
* Identifiants de connexion LDAP autorisés à faire de l'usurpation d'identité.
* NB: à réserver exclusivement aux tests.
*/
// 'usurpation_allowed_usernames' => array(),
);
/**
* You do not need to edit below this line
*/
return array(
'unicaen-auth' => $settings,
);
\ No newline at end of file
<?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>
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment