From 1d0c8acbf8a2d8eddd0a47882bad2a96f3654fdb Mon Sep 17 00:00:00 2001 From: Nicholas Calugar Date: Sun, 12 Aug 2012 20:27:28 -0700 Subject: [PATCH] Updating bootstrap to get rid of Di and use ServiceManager --- tests/ZendSkeletonModule/SampleTest.php | 2 +- tests/bootstrap.php | 49 ++++++++----------------- 2 files changed, 16 insertions(+), 35 deletions(-) diff --git a/tests/ZendSkeletonModule/SampleTest.php b/tests/ZendSkeletonModule/SampleTest.php index 0a74792..73a3568 100644 --- a/tests/ZendSkeletonModule/SampleTest.php +++ b/tests/ZendSkeletonModule/SampleTest.php @@ -14,6 +14,6 @@ class SampleTest extends Framework\TestCase public function testSample() { - $this->assertInstanceOf('Zend\Di\LocatorInterface', $this->getLocator()); + $this->assertInstanceOf('Zend\ServiceManager\ServiceLocatorInterface', $this->getLocator()); } } diff --git a/tests/bootstrap.php b/tests/bootstrap.php index 8e37281..70c9d11 100644 --- a/tests/bootstrap.php +++ b/tests/bootstrap.php @@ -33,7 +33,7 @@ // setup autoloader AutoloaderFactory::factory( array( - 'Zend\Loader\StandardAutoloader' => array( + 'Zend\Loader\StandardAutoloader' => array( StandardAutoloader::AUTOREGISTER_ZF => true, StandardAutoloader::ACT_AS_FALLBACK => false, StandardAutoloader::LOAD_NS => $additionalNamespaces, @@ -62,42 +62,23 @@ $modules = array_merge($modules, $moduleDependencies); } -$listenerOptions = new Zend\ModuleManager\Listener\ListenerOptions(array('module_paths' => $modulePaths)); -$defaultListeners = new Zend\ModuleManager\Listener\DefaultListenerAggregate($listenerOptions); -$moduleManager = new \Zend\ModuleManager\ModuleManager($modules); -$moduleManager->getEventManager()->attachAggregate($defaultListeners); -$moduleManager->loadModules(); - -if (method_exists($moduleTestCaseClassname, 'setLocator')) { - $config = $defaultListeners->getConfigListener()->getMergedConfig(); - - $di = new \Zend\Di\Di; - $di->instanceManager()->addTypePreference('Zend\Di\LocatorInterface', $di); - - if (isset($config['di'])) { - $diConfig = new \Zend\Di\Config($config['di']); - $diConfig->configure($di); - } +$config = array( + 'module_listener_options' => array( + 'module_paths' => $modulePaths, + ), + 'modules' => $modules, +); - $routerDiConfig = new \Zend\Di\Config( - array( - 'definition' => array( - 'class' => array( - 'Zend\Mvc\Router\RouteStackInterface' => array( - 'instantiator' => array( - 'Zend\Mvc\Router\Http\TreeRouteStack', - 'factory' - ), - ), - ), - ), - ) - ); - $routerDiConfig->configure($di); +$serviceManager = new \Zend\ServiceManager\ServiceManager( + new \Zend\Mvc\Service\ServiceManagerConfig() +); +$serviceManager->setService('ApplicationConfig', $config); +$serviceManager->get('ModuleManager')->loadModules(); - call_user_func_array($moduleTestCaseClassname.'::setLocator', array($di)); +if (method_exists($moduleTestCaseClassname, 'setLocator')) { + call_user_func_array($moduleTestCaseClassname.'::setLocator', array($serviceManager)); } // When this is in global scope, PHPUnit catches exception: // Exception: Zend\Stdlib\PriorityQueue::serialize() must return a string or NULL -unset($moduleManager); +unset($serviceManager);