diff --git a/Module.php b/Module.php new file mode 100644 index 0000000000000000000000000000000000000000..4afc351a6e02c7705cae3a873882cd0a76846b2c --- /dev/null +++ b/Module.php @@ -0,0 +1,28 @@ +<?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'; + } +} diff --git a/autoload_classmap.php b/autoload_classmap.php new file mode 100644 index 0000000000000000000000000000000000000000..358927338d7822435f5d120552919ec5ac32fd43 --- /dev/null +++ b/autoload_classmap.php @@ -0,0 +1,5 @@ +<?php +// Generated by ZF2's ./bin/classmap_generator.php +return array( + 'UnicaenImport\Module' => __DIR__ . '/Module.php', +); diff --git a/composer.json b/composer.json new file mode 100644 index 0000000000000000000000000000000000000000..08c0ad5f4be7ae86620a5792efa6db25bef07043 --- /dev/null +++ b/composer.json @@ -0,0 +1,26 @@ +{ + "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" + ] + } +} diff --git a/config/module.config.php b/config/module.config.php new file mode 100644 index 0000000000000000000000000000000000000000..8cbd0ff98c71bc0736cd6d29eb77a810ebe34828 --- /dev/null +++ b/config/module.config.php @@ -0,0 +1,6 @@ +<?php + +return [ + 'unicaen-import' => [ + ] +]; diff --git a/config/unicaen-import.global.php.dist b/config/unicaen-import.global.php.dist new file mode 100644 index 0000000000000000000000000000000000000000..b62512838d61fcfb139998b7643eec0db85d6ede --- /dev/null +++ b/config/unicaen-import.global.php.dist @@ -0,0 +1,4 @@ +<?php + +return [ +]; diff --git a/nbproject/project.properties b/nbproject/project.properties new file mode 100644 index 0000000000000000000000000000000000000000..76f6f918396fa724692f20def125cd2d84c4755d --- /dev/null +++ b/nbproject/project.properties @@ -0,0 +1,7 @@ +include.path=${php.global.include.path} +php.version=PHP_56 +source.encoding=UTF-8 +src.dir=. +tags.asp=false +tags.short=false +web.root=. diff --git a/nbproject/project.xml b/nbproject/project.xml new file mode 100644 index 0000000000000000000000000000000000000000..a93bd6c05c70e5336379aea8743650e5b60edef8 --- /dev/null +++ b/nbproject/project.xml @@ -0,0 +1,9 @@ +<?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> diff --git a/tests/Bootstrap.php b/tests/Bootstrap.php new file mode 100644 index 0000000000000000000000000000000000000000..cecb19654ca400f66ef7f8f4ca781ade2040e180 --- /dev/null +++ b/tests/Bootstrap.php @@ -0,0 +1,97 @@ +<?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(); diff --git a/tests/config/application.config.php b/tests/config/application.config.php new file mode 100644 index 0000000000000000000000000000000000000000..3a3d385d802b2e98d809df9110f73a8665a915e7 --- /dev/null +++ b/tests/config/application.config.php @@ -0,0 +1,18 @@ +<?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); diff --git a/tests/config/autoload/global.php b/tests/config/autoload/global.php new file mode 100644 index 0000000000000000000000000000000000000000..881ab67d036d4900e0c6aef94f47961fe0c03b5a --- /dev/null +++ b/tests/config/autoload/global.php @@ -0,0 +1,2 @@ +<?php +return []; diff --git a/tests/phpunit.xml b/tests/phpunit.xml new file mode 100644 index 0000000000000000000000000000000000000000..59dc2ca0d31cbe77c0e4fec96708713f39deee15 --- /dev/null +++ b/tests/phpunit.xml @@ -0,0 +1,24 @@ +<?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>