Magento 2 Documentation  2.3
Documentation for Magento 2 CMS v2.3 (December 2018)
PhpUnitAnalyzer.php
Go to the documentation of this file.
1 <?php
8 
9 use Magento\Mtf\ObjectManagerInterface;
10 use Symfony\Component\Console\Input\InputInterface;
11 use Symfony\Component\Console\Output\OutputInterface;
12 
16 class PhpUnitAnalyzer extends \Symfony\Component\Console\Command\Command
17 {
23  private $objectManager;
24 
28  public function __construct(ObjectManagerInterface $objectManager)
29  {
30  parent::__construct();
31  $this->objectManager = $objectManager;
32  }
33 
39  protected function configure()
40  {
41  parent::configure();
42  $this->setName('troubleshooting:check-phpunit-config-file')
43  ->setDescription('Check if phpunit file is available.');
44  }
45 
54  protected function execute(InputInterface $input, OutputInterface $output)
55  {
56  $output = $this->objectManager->create(
57  \Magento\Mtf\Console\Output::class,
58  ['output' => $output]
59  );
60  $output->writeln("Checking phpunit.xml file availability...");
61  $messages = [];
62  $configFileExists = false;
63  if (file_exists(MTF_PHPUNIT_FILE)) {
64  $configFileExists = true;
65  } else {
66  if (file_exists(MTF_PHPUNIT_FILE . '.dist')) {
67  if (!copy(MTF_PHPUNIT_FILE . '.dist', MTF_PHPUNIT_FILE)) {
68  $messages['error'][] = 'Failed to copy phpunit.xml.dist to phpunit.xml.';
69  } else {
70  $messages['info'][] = 'phpunit.xml file has been created based on phpunit.xml.dist. '
71  . 'Please, adjust your PHPUnit configuration to use new file.';
72  $configFileExists = true;
73  }
74  }
75  }
76  if (!$configFileExists) {
77  $messages['error'][] = 'Cannot define phpunit configuration path.';
78  }
79  $output->outputMessages($messages);
80  $output->writeln("phpunit.xml check finished.");
81  }
82 }
execute(InputInterface $input, OutputInterface $output)
$objectManager
Definition: bootstrap.php:17
__construct(ObjectManagerInterface $objectManager)