|
| 1 | +<?php |
| 2 | +// @codingStandardsIgnoreFile |
| 3 | +/** |
| 4 | + * Copyright © Magento, Inc. All rights reserved. |
| 5 | + * See COPYING.txt for license details. |
| 6 | + */ |
| 7 | +declare(strict_types = 1); |
| 8 | + |
| 9 | +namespace Magento\FunctionalTestingFramework\Console; |
| 10 | + |
| 11 | +use Magento\FunctionalTestingFramework\StaticCheck\StaticChecksList; |
| 12 | +use Magento\FunctionalTestingFramework\Util\Logger\LoggingUtil; |
| 13 | +use Symfony\Component\Console\Command\Command; |
| 14 | +use Symfony\Component\Console\Input\InputInterface; |
| 15 | +use Symfony\Component\Console\Input\InputArgument; |
| 16 | +use Symfony\Component\Console\Output\OutputInterface; |
| 17 | + |
| 18 | +class StaticChecksCommand extends Command |
| 19 | +{ |
| 20 | + /** |
| 21 | + * Pool of static check scripts to run |
| 22 | + * |
| 23 | + * @var \Magento\FunctionalTestingFramework\StaticCheck\StaticCheckListInterface |
| 24 | + */ |
| 25 | + private $staticChecksList; |
| 26 | + |
| 27 | + /** |
| 28 | + * Configures the current command. |
| 29 | + * |
| 30 | + * @return void |
| 31 | + */ |
| 32 | + protected function configure() |
| 33 | + { |
| 34 | + $this->setName('static-checks') |
| 35 | + ->setDescription('This command will run all static checks on xml test materials.'); |
| 36 | + $this->staticChecksList = new StaticChecksList(); |
| 37 | + } |
| 38 | + |
| 39 | + /** |
| 40 | + * |
| 41 | + * |
| 42 | + * @param InputInterface $input |
| 43 | + * @param OutputInterface $output |
| 44 | + * @return int|null|void |
| 45 | + * @throws \Exception |
| 46 | + */ |
| 47 | + protected function execute(InputInterface $input, OutputInterface $output) |
| 48 | + { |
| 49 | + $staticCheckObjects = $this->staticChecksList->getStaticChecks(); |
| 50 | + foreach ($staticCheckObjects as $staticCheck) { |
| 51 | + $staticOutput = $staticCheck->execute($input); |
| 52 | + LoggingUtil::getInstance()->getLogger(get_class($staticCheck))->info($staticOutput); |
| 53 | + $output->writeln($staticOutput); |
| 54 | + } |
| 55 | + } |
| 56 | +} |
0 commit comments