Skip to content
Snippets Groups Projects
Commit e41c14cb authored by Laurent Lecluse's avatar Laurent Lecluse
Browse files

Initialisation du module

parent 2d6661d6
No related branches found
No related tags found
No related merge requests found
<?php
namespace UnicaenImport;
use Zend\ModuleManager\Feature\ConfigProviderInterface;
use Zend\Mvc\MvcEvent;
include_once 'Functions.php';
/**
*
*
* @author Laurent LECLUSE <laurent.lecluse at unicaen.fr>
*/
class Module implements ConfigProviderInterface
{
public function onBootstrap(MvcEvent $e)
{
}
public function getConfig()
{
return include __DIR__ . '/config/module.config.php';
}
}
<?php
// Generated by ZF2's ./bin/classmap_generator.php
return array(
'UnicaenImport\Module' => __DIR__ . '/Module.php',
);
{
"name" : "unicaen/unicaen-import",
"description" : "Boite à outils pour la programmation avec la bibliothèque Unicaen",
"repositories": [
{
"type": "composer",
"url" : "http://dev.unicaen.fr/packagist"
}
],
"require" : {
},
"require-dev" : {
"phpunit/PHPUnit" : ">=3.7",
},
"autoload" : {
"psr-0" : {
"UnicaenImport" : "src/",
"UnicaenImportTest": "tests/"
},
"classmap": [
"./Module.php"
]
}
}
<?php
return [
'unicaen-import' => [
]
];
<?php
return [
];
include.path=${php.global.include.path}
php.version=PHP_56
source.encoding=UTF-8
src.dir=.
tags.asp=false
tags.short=false
web.root=.
<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://www.netbeans.org/ns/project/1">
<type>org.netbeans.modules.php.project</type>
<configuration>
<data xmlns="http://www.netbeans.org/ns/php-project/1">
<name>unicaen-import</name>
</data>
</configuration>
</project>
<?php
namespace UnicaenImportTest;
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(
'UnicaenImport'
),
'module_listener_options' => array(
'config_glob_paths' => array(
__DIR__ . '/autoload/{,*.}{global,local}.php',
),
),
);
return \Zend\Stdlib\ArrayUtils::merge($appConfig, $testConfig);
<?php
return [];
<?xml version="1.0" encoding="UTF-8"?>
<phpunit bootstrap="./Bootstrap.php" colors="true">
<testsuites>
<testsuite name="UnicaenImport">
<directory>./UnicaenImportTest</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>
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment