public function testGetGetsAnModule()
 {
     $modules = new Modules();
     $module = $this->getMockForAbstractClass(AbstractModule::CLASS);
     $modules->set('foo', $module);
     $this->assertSame($module, $modules->get('foo'));
 }
 public function testInvoke()
 {
     $modules = new Modules();
     $module = new \Foo\Module();
     $modules->set('foo', $module);
     $config = new SystemConfig();
     $listener = new ConfigReaderModulesListener();
     $listener->setConfig($config);
     $listener->setModules($modules);
     $listener(new ModulesEvent());
     $this->assertSame($module->getConfig(), $config->toArray());
 }
 public function testInvoke()
 {
     $module = $this->getMock(AbstractModule::CLASS);
     $src = $module->getModuleDir() . PHP_DS . 'src';
     $loader = $this->getMock(ClassLoader::CLASS);
     $modules = new Modules();
     $modules->set('foo', $module);
     $listener = new RegistrationListener();
     $listener->setModules($modules);
     $listener->setLoader($loader);
     $loader->expects($this->once())->method('registerPath')->with($this->identicalTo('foo'), $this->identicalTo($src));
     $listener(new ModulesEvent());
 }
 public function testInvokeOnSuccess()
 {
     $modules = new Modules();
     $module = $this->getMock(AbstractModule::CLASS);
     $modules->set(__NAMESPACE__, $module);
     $view = new View();
     $listener = new InjectModuleListener();
     $listener->setModules($modules);
     $listener->setView($view);
     $event = new SystemEvent();
     $model = new ViewModel();
     $controller = new FakeController();
     $event->setContext($controller);
     $event->setResult(SystemEvent::DISPATCH, $model);
     $listener($event);
     $layout = $view->getLayout();
     $this->assertSame(__NAMESPACE__, $layout->getModule());
     $this->assertSame(__NAMESPACE__, $model->getModule());
 }
 public function testInvoke()
 {
     $modules = new Modules();
     $module = $this->getMock(AbstractModule::CLASS);
     $modules->set('Foo', $module);
     $services = new Services();
     $services->set('Modules', $modules);
     $this->setServices($services);
     $rootModel = $this->getMock(ViewModel::CLASS, ['addChild']);
     $toolbarEvent = new ToolbarEvent($rootModel);
     $model = new ViewModel();
     $listener = new ModulesListener();
     $listener->setModel($model);
     $rootModel->expects($this->once())->method('addChild')->with($this->identicalTo($model));
     $listener($toolbarEvent);
     $this->assertTrue(isset($model['modules']));
     $items = $model['modules'];
     $this->assertInternalType('array', $items);
     $this->assertSame(1, count($items));
     $this->assertArrayHasKey('Foo', $items);
 }
 public function testInvokeRegisterModulePath()
 {
     $moduleName = 'Foo';
     $module = $this->getMock(AbstractModule::CLASS);
     $moduleDir = $module->getModuleDir();
     $modules = new Modules();
     $modules->set($moduleName, $module);
     $resolver = $this->getMock(Resolver::CLASS);
     $config = new SystemConfig();
     $listener = new ConfigureResolverListener();
     $listener->setModules($modules);
     $listener->setResolver($resolver);
     $listener->setConfig($config);
     $resolver->expects($this->once())->method('registerModulePath')->with($this->identicalTo($moduleName), $this->identicalTo($moduleDir));
     $listener(new ModulesEvent());
 }