private function initializeRules() { $this->logger->debug('Initialization of rules started'); $this->downloadRules = []; $rules = $this->configurationProvider->getRulesNames(); $this->logger->debug('Found ' . count($rules) . ' rule(s)'); foreach ($rules as $ruleName) { $this->logger->debug("Initializing {$ruleName} rule"); $this->downloadRules[] = $this->configurationProvider->getRule($ruleName); //In that case it will never return false since names are sourced from getRulesNames() $this->logger->debug("{$ruleName} rule initialized"); } $this->logger->debug('All rules ready'); }
/** * @inheritDoc */ protected function execute(InputInterface $input, OutputInterface $output) { $logger = $this->getLogger($input->getOption('log'), $output->getVerbosity()); //If it crash here it will just crash without fancy-pancy error message, sorry! $logger->info('Starting ' . ConsoleApplication::NAME . ' v' . ConsoleApplication::VERSION); if (version_compare(PHP_VERSION, '5.5.0', '<')) { $logger->warning('You\'re using outdated version of PHP (v' . PHP_VERSION . '). ' . ConsoleApplication::NAME . ' should work, but may be unstable or you may experience bugs. It\'s recommended to upgrade your ' . 'system. See http://php.net/eol.php for further details.'); } try { //TODO handle POSIX signal to reload config (and these two lines should be than extracted to method) $configurationProvider = ConfigurationProvider::fromYamlFile($input->getOption('config'), $logger); $application = new Application($configurationProvider, $logger); $application->run(); } catch (\Exception $e) { $logger->emergency($this->getClassNameFromObject($e) . ': ' . $e->getMessage()); return self::POSIX_EXIT_ERROR; } $logger->info(ConsoleApplication::NAME . ' finished'); return self::POSIX_EXIT_OK; }
public function testGetRuleReturnsFalseForUnknownRule() { $configuration = $this->subjectUnderTest->getRule('PiratedStuff'); $this->assertFalse($configuration); }