/** * 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; }
/** * @dataProvider supplyTestSharedFactoriesServices * @group service_factories * @group service_shared */ public function testSharedFactoriesServices($config, $equal) { $diMock = new Di($config); $di = new DiManager($diMock); $di->initFactoriedServices(); $obj1 = $di->getDI()->get('myObject'); $this->assertInstanceOf(DateObject::class, $obj1); usleep(100000); $obj2 = $di->getDI()->get('myObject'); $this->assertInstanceOf(DateObject::class, $obj2); $this->assertEquals($equal, $obj1->time === $obj2->time); }