From 6992fe8a66718fa841b55e652be5238f25d2572a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Andreas=20Mo=CC=88ller?= Date: Sat, 22 Nov 2014 14:29:02 +0100 Subject: [PATCH] Fix: Autoload with composer --- .travis.yml | 3 -- Module.php | 18 ++--------- autoload_classmap.php | 11 ------- composer.json | 5 ++++ test/TestConfig.php.dist | 1 - test/{ => ZfcBaseTest}/Bootstrap.php | 45 +++------------------------- test/bootstrap.php | 11 +++++++ test/phpunit.xml | 2 +- 8 files changed, 23 insertions(+), 73 deletions(-) delete mode 100644 autoload_classmap.php rename test/{ => ZfcBaseTest}/Bootstrap.php (56%) create mode 100644 test/bootstrap.php diff --git a/.travis.yml b/.travis.yml index fcb3e4c..a0b813f 100644 --- a/.travis.yml +++ b/.travis.yml @@ -6,8 +6,5 @@ php: - 5.4 - 5.5 -env: - - ZF2_PATH=./vendor/zendframework/zendframework/library - script: - phpunit --configuration test/phpunit.xml diff --git a/Module.php b/Module.php index 073d4e7..ce2b104 100644 --- a/Module.php +++ b/Module.php @@ -2,21 +2,7 @@ namespace ZfcBase; -use Zend\ModuleManager\Feature\AutoloaderProviderInterface; - -class Module implements AutoloaderProviderInterface +class Module { - public function getAutoloaderConfig() - { - return array( - 'Zend\Loader\ClassMapAutoloader' => array( - __DIR__ . '/autoload_classmap.php', - ), - 'Zend\Loader\StandardAutoloader' => array( - 'namespaces' => array( - __NAMESPACE__ => __DIR__ . '/src/' . __NAMESPACE__, - ), - ), - ); - } + } diff --git a/autoload_classmap.php b/autoload_classmap.php deleted file mode 100644 index 74bb9ce..0000000 --- a/autoload_classmap.php +++ /dev/null @@ -1,11 +0,0 @@ - __DIR__ . '/Module.php', - 'ZfcBase\Form\ProvidesEventsForm' => __DIR__ . '/src/ZfcBase/Form/ProvidesEventsForm.php', - 'ZfcBase\Mapper\Exception\ExceptionInterface' => __DIR__ . '/src/ZfcBase/Mapper/Exception/ExceptionInterface.php', - 'ZfcBase\Mapper\Exception\InvalidArgumentException' => __DIR__ . '/src/ZfcBase/Mapper/Exception/InvalidArgumentException.php', - 'ZfcBase\Mapper\AbstractDbMapper' => __DIR__ . '/src/ZfcBase/Mapper/AbstractDbMapper.php', - 'ZfcBase\EventManager\EventProvider' => __DIR__ . '/src/ZfcBase/EventManager/EventProvider.php', - 'ZfcBase\Module\AbstractModule' => __DIR__ . '/src/ZfcBase/Module/AbstractModule.php', -); \ No newline at end of file diff --git a/composer.json b/composer.json index e2c5e22..0bcf89a 100644 --- a/composer.json +++ b/composer.json @@ -38,5 +38,10 @@ "classmap": [ "./Module.php" ] + }, + "autoload-dev": { + "psr-0": { + "ZfcBaseTest\\": "test/" + } } } diff --git a/test/TestConfig.php.dist b/test/TestConfig.php.dist index 79f7d42..764ea9a 100644 --- a/test/TestConfig.php.dist +++ b/test/TestConfig.php.dist @@ -1,5 +1,4 @@ array( diff --git a/test/Bootstrap.php b/test/ZfcBaseTest/Bootstrap.php similarity index 56% rename from test/Bootstrap.php rename to test/ZfcBaseTest/Bootstrap.php index 8c5443b..8aa94fd 100644 --- a/test/Bootstrap.php +++ b/test/ZfcBaseTest/Bootstrap.php @@ -1,14 +1,10 @@ array( @@ -56,35 +50,6 @@ public static function getServiceManager() return static::$serviceManager; } - protected static function initAutoloader() - { - $vendorPath = static::findParentPath('vendor'); - - if (is_readable($vendorPath . '/autoload.php')) { - $loader = include $vendorPath . '/autoload.php'; - } - - $zf2Path = getenv('ZF2_PATH') ?: (defined('ZF2_PATH') ? ZF2_PATH : (is_dir($vendorPath . '/ZF2/library') ? $vendorPath . '/ZF2/library' : false)); - - if (!$zf2Path) { - throw new RuntimeException('Unable to load ZF2. Run `php composer.phar install` or define a ZF2_PATH environment variable.'); - } - - if (isset($loader)) { - $loader->add('Zend', $zf2Path . '/Zend'); - } else { - 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__; @@ -97,5 +62,3 @@ protected static function findParentPath($path) return $dir . '/' . $path; } } - -Bootstrap::init(); diff --git a/test/bootstrap.php b/test/bootstrap.php new file mode 100644 index 0000000..123f661 --- /dev/null +++ b/test/bootstrap.php @@ -0,0 +1,11 @@ + + ./ZfcBaseTest