public function beforeCompile() { parent::beforeCompile(); // Get container builder $builder = $this->getContainerBuilder(); // Get validators service $factory = $builder->getDefinition($this->prefix('validators')); foreach (array_keys($builder->findByTag(self::TAG_VALIDATOR)) as $serviceName) { // Register validator to service $factory->addSetup('registerValidator', ['@' . $serviceName, $serviceName]); } }
/** * @return \TestPresenter */ private function createPresenter() { $url = new \Nette\Http\UrlScript('http://localhost/'); $url->setScriptPath('/'); $configurator = new \Nette\Config\Configurator(); $configurator->addConfig(__DIR__ . '/config.neon'); \Kdyby\Events\DI\EventsExtension::register($configurator); \Kdyby\Annotations\DI\AnnotationsExtension::register($configurator); \Kdyby\Doctrine\DI\OrmExtension::register($configurator); $container = $configurator->setTempDirectory(TEMP_DIR)->createContainer(); $container->removeService('httpRequest'); $container->addService('httpRequest', new \Nette\Http\Request($url)); $application = $container->getService('application'); $application->router[] = new \Nette\Application\Routers\SimpleRouter(); $presenter = new TestPresenter($container); $container->callInjects($presenter); $presenter->invalidLinkMode = $presenter::INVALID_LINK_WARNING; $presenter->autoCanonicalize = FALSE; return $presenter; }
protected function beforeSetUp() { ConsoleExtension::register($this->getConfigurator()); OrmExtension::register($this->getConfigurator()); EventsExtension::register($this->getConfigurator()); }