public function testCreateDetector() { $configuration = $this->prophesize('SensioLabs\\DeprecationDetector\\Configuration\\Configuration'); $output = $this->prophesize('Symfony\\Component\\Console\\Output\\OutputInterface'); $factory = new DetectorFactory(); $this->assertInstanceOf('SensioLabs\\DeprecationDetector\\DeprecationDetector', $factory->create($configuration->reveal(), $output->reveal())); }
/** * @param InputInterface $input * @param OutputInterface $output * * @return int * * @throws \RuntimeException */ protected function execute(InputInterface $input, OutputInterface $output) { $sourceArg = realpath($input->getArgument('source')); $ruleSetArg = realpath($input->getArgument('ruleset')); if (false === $sourceArg || false === $ruleSetArg) { throw new \InvalidArgumentException(sprintf('%s argument is invalid: "%s" is not a path.', $sourceArg ? 'Rule set' : 'Source directory', $sourceArg ? $input->getArgument('ruleset') : $input->getArgument('source'))); } $config = new Configuration($input->getArgument('ruleset'), $input->getOption('container-cache'), $input->getOption('no-cache'), $input->getOption('cache-dir'), $input->getOption('filter-methods'), $input->getOption('fail'), $input->getOption('verbose'), $input->getOption('log-html'), $input->getOption('output')); $factory = new DetectorFactory(); $detector = $factory->create($config, $output); $violations = $detector->checkForDeprecations($sourceArg, $ruleSetArg); if ($config->failOnDeprecation() && !empty($violations)) { return 1; } return 0; }