Ejemplo n.º 1
0
 /**
  * Initialize phalcon application
  * @return PhalconApplication
  */
 protected function initPhalconApplication()
 {
     $diFactory = $this->diManager->getDI();
     $moduleHandler = $diFactory->get('moduleHandler');
     // Register autoloader
     (new Autoloader($diFactory))->register();
     // Register services and routers
     $this->diManager->initInvokableServices()->initFactoriedServices()->initRouterDi();
     // Init listeners
     (new Listener($diFactory))->listenApplicationEvents(new Listener\Application())->listenDispatchEvents(new Listener\Dispatch());
     // Register modules
     $application = new PhalconApplication($diFactory);
     $application->setEventsManager($diFactory['eventsManager']);
     $application->registerModules($moduleHandler->getRegisteredModules());
     return $application;
 }
Ejemplo n.º 2
0
 /**
  * @group service_invokables
  * @group service_factories
  */
 public function testInitServicesWithoutConfig()
 {
     $config = [];
     $diMock = $this->getMock(Di::class, ['get'], [[]]);
     $diMock->expects($this->once())->method('get')->with('config')->will($this->returnValue(new Config($config)));
     $diMock->expects($this->never())->method('set');
     $di = new DiManager($diMock);
     $di->initInvokableServices();
     $di->initFactoriedServices();
 }