-
Notifications
You must be signed in to change notification settings - Fork 132
/
Copy pathStaticChecksCommand.php
69 lines (60 loc) · 1.85 KB
/
StaticChecksCommand.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
<?php
// @codingStandardsIgnoreFile
/**
* Copyright © Magento, Inc. All rights reserved.
* See COPYING.txt for license details.
*/
declare(strict_types = 1);
namespace Magento\FunctionalTestingFramework\Console;
use Magento\FunctionalTestingFramework\StaticCheck\StaticChecksList;
use Magento\FunctionalTestingFramework\StaticCheck\StaticCheckListInterface;
use Magento\FunctionalTestingFramework\Util\Logger\LoggingUtil;
use Symfony\Component\Console\Command\Command;
use Symfony\Component\Console\Input\InputInterface;
use Symfony\Component\Console\Output\OutputInterface;
use Exception;
class StaticChecksCommand extends Command
{
/**
* Pool of static check scripts to run
*
* @var StaticCheckListInterface
*/
private $staticChecksList;
/**
* Configures the current command.
*
* @return void
*/
protected function configure()
{
$this->setName('static-checks')
->setDescription('This command will run all static checks on xml test materials.');
$this->staticChecksList = new StaticChecksList();
}
/**
*
*
* @param InputInterface $input
* @param OutputInterface $output
* @return int
* @throws Exception
*/
protected function execute(InputInterface $input, OutputInterface $output)
{
$staticCheckObjects = $this->staticChecksList->getStaticChecks();
$errors = [];
foreach ($staticCheckObjects as $staticCheck) {
$staticCheck->execute($input);
$staticOutput = $staticCheck->getOutput();
LoggingUtil::getInstance()->getLogger(get_class($staticCheck))->info($staticOutput);
$output->writeln($staticOutput);
$errors += $staticCheck->getErrors();
}
if (empty($errors)) {
return 0;
} else {
return 1;
}
}
}