Commit 148a9ee7 authored by Laurent Lécluse's avatar Laurent Lécluse
Browse files

Mise en place du skelette

parent 850eeedf
<?php
namespace UnicaenLdap;
use Zend\ModuleManager\Feature\AutoloaderProviderInterface;
use Zend\ModuleManager\Feature\ConfigProviderInterface;
use Zend\ModuleManager\Feature\ServiceProviderInterface;
/**
*
*
* @author Laurent LECLUSE <laurent.lecluse at unicaen.fr>
*/
class Module implements ConfigProviderInterface, ServiceProviderInterface
{
/**
*
* @return array
* @see ConfigProviderInterface
*/
public function getConfig()
{
return include __DIR__ . '/config/module.config.php';
}
/**
*
* @return array
* @see AutoloaderProviderInterface
*/
public function getAutoloaderConfig()
{
return array(
'Zend\Loader\ClassMapAutoloader' => array(
__DIR__ . '/autoload_classmap.php',
),
'Zend\Loader\StandardAutoloader' => array(
'namespaces' => array(
__NAMESPACE__ => __DIR__ . '/src/' . __NAMESPACE__,
),
),
);
}
/**
*
* @return array
* @see ServiceProviderInterface
*/
public function getServiceConfig()
{
return array(
'factories' => array(
'UnicaenLdap\Options\ModuleOptions' => 'UnicaenLdap\Options\ModuleOptionsFactory',
),
);
}
}
<?php
// Generated by ZF2's ./bin/classmap_generator.php
return array(
);
\ No newline at end of file
{
"name": "unicaen/unicaen-ldap",
"description": "Module Ldap de l'UCBN",
"repositories": [
{
"type": "composer",
"url": "http://dev.unicaen.fr/packagist"
}
],
"require": {
},
"require-dev": {
"phpunit/PHPUnit": ">=3.7",
"zendframework/zend-test": ">=2.2"
},
"autoload": {
"psr-0": {
"UnicaenLdap": "src/",
"UnicaenLdapTest": "tests/"
},
"classmap": [
"./Module.php"
]
}
}
<?php
$settings = array(
);
return array(
'unicaen-ldap' => $settings
);
<?php
$settings = array(
);
return array(
'unicaen-ldap' => $settings
);
<?php
$settings = array(
);
return array(
'unicaen-ldap' => $settings
);
<?php
namespace UnicaenLdap\Options;
/**
* Classe encapsulant les options de fonctionnement du module.
*
* @author Laurent LECLUSE <laurent.lecluse at unicaen.fr>
*/
class ModuleOptions extends \ZfcUser\Options\ModuleOptions
{
}
<?php
namespace UnicaenLdap\Options;
use Zend\ServiceManager\FactoryInterface;
use Zend\ServiceManager\ServiceLocatorInterface;
/**
* Description of ModuleOptionsFactory
*
* @author Laurent LECLUSE <laurent.lecluse at unicaen.fr>
*/
class ModuleOptionsFactory implements FactoryInterface
{
/**
* Create service
*
* @param ServiceLocatorInterface $serviceLocator
* @return mixed
*/
public function createService(ServiceLocatorInterface $serviceLocator)
{
$config = $serviceLocator->get('Configuration');
$moduleConfig = isset($config['unicaen-ldap']) ? $config['unicaen-ldap'] : array();
return new ModuleOptions($moduleConfig);
}
}
<?php
namespace UnicaenLdapTest;
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
{
/**
*
* @var ServiceManager
*/
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();
// use ModuleManager to load this module and it's dependencies
$serviceManager = new ServiceManager(new ServiceManagerConfig());
$serviceManager->setService('ApplicationConfig', require_once './config/application.config.php');
$serviceManager->get('ModuleManager')->loadModules();
static::$serviceManager = $serviceManager;
}
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();
<?php
// Application config
$appConfig = array();//include __DIR__ . '/../../../../../config/application.config.php';
// Test config
$testConfig = array(
'modules' => array(
'UnicaenLdap'
),
'module_listener_options' => array(
'config_glob_paths' => array(
__DIR__ . '/autoload/{,*.}{global,local}.php',
),
),
);
return \Zend\Stdlib\ArrayUtils::merge($appConfig, $testConfig);
<?php
$settings = array(
);
/**
* You do not need to edit below this line
*/
return array(
'unicaen-ldap' => $settings,
);
<?php
$settings = array(
);
/**
* You do not need to edit below this line
*/
return array(
'unicaen-ldap' => $settings,
);
<?xml version="1.0" encoding="UTF-8"?>
<phpunit bootstrap="./Bootstrap.php" colors="true">
<testsuites>
<testsuite name="UnicaenLdap">
<directory>./UnicaenLdapTest</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>
</groups>
</phpunit>
Supports Markdown
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