Magento 2 Documentation  2.3
Documentation for Magento 2 CMS v2.3 (December 2018)
I18nCollectPhrasesCommandTest.php
Go to the documentation of this file.
1 <?php
7 
8 use Symfony\Component\Console\Tester\CommandTester;
9 
10 class I18nCollectPhrasesCommandTest extends \PHPUnit\Framework\TestCase
11 {
15  private $command;
16 
20  private $tester;
21 
22  public function setUp()
23  {
24  $this->command = new I18nCollectPhrasesCommand();
25  $this->tester = new CommandTester($this->command);
26  }
27 
28  public function tearDown()
29  {
30  $property = new \ReflectionProperty(\Magento\Setup\Module\I18n\ServiceLocator::class, '_dictionaryGenerator');
31  $property->setAccessible(true);
32  $property->setValue(null);
33  $property->setAccessible(false);
34  }
35 
36  public function testExecuteConsoleOutput()
37  {
38  $this->tester->execute(
39  [
40  'directory' => BP . '/dev/tests/integration/testsuite/Magento/Setup/Console/Command/_files/',
41  ]
42  );
43 
44  $this->assertEquals('Dictionary successfully processed.' . PHP_EOL, $this->tester->getDisplay());
45  }
46 
47  public function testExecuteCsvOutput()
48  {
49  $outputPath = BP . '/dev/tests/integration/testsuite/Magento/Setup/Console/Command/_files/output/phrases.csv';
50  $this->tester->execute(
51  [
52  'directory' => BP . '/dev/tests/integration/testsuite/Magento/Setup/Console/Command/_files/phrases/',
53  '--output' => $outputPath,
54  ]
55  );
56 
57  $handle = fopen($outputPath, 'r');
58  $output = fread($handle, filesize($outputPath));
59  $expected = file_get_contents(
60  BP . '/dev/tests/integration/testsuite/Magento/Setup/Console/Command/_files/expectedPhrases.csv'
61  );
62  $this->assertEquals($expected, $output);
63  unlink($outputPath);
64  }
65 
70  public function testExecuteNonExistingPath()
71  {
72  $this->tester->execute(
73  [
74  'directory' => BP . '/dev/tests/integration/testsuite/Magento/Setup/Console/Command/_files/non_exist',
75  ]
76  );
77  }
78 
84  {
85  $this->tester->execute(['directory' => 'a', '--magento' => true]);
86  }
87 
93  {
94  $this->tester->execute([]);
95  }
96 }
const BP
Definition: autoload.php:14
$handle