123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596 |
- <?php
- /**
- * Copyright © Magento, Inc. All rights reserved.
- * See COPYING.txt for license details.
- */
- namespace Magento\Setup\Console\Command;
- use Symfony\Component\Console\Tester\CommandTester;
- /**
- * @magentoComponentsDir Magento/Setup/Console/Command/_files/root/app/code
- */
- class I18nPackCommandTest extends \PHPUnit\Framework\TestCase
- {
- /**
- * @var I18nCollectPhrasesCommand
- */
- private $command;
- /**
- * @var CommandTester
- */
- private $tester;
- public function setUp()
- {
- $this->command = new I18nPackCommand();
- $this->tester = new CommandTester($this->command);
- }
- public function tearDown()
- {
- $this->removeCsv('A');
- $this->removeCsv('B');
- $this->removeCsv('C');
- $this->removeCsv('D');
- }
- private function removeCsv($module)
- {
- if (file_exists(__DIR__ . "/_files/root/app/code/Magento/{$module}/i18n")) {
- $helper = new \Magento\Framework\Backup\Filesystem\Helper();
- $helper->rm(__DIR__ . "/_files/root/app/code/Magento/{$module}/i18n", [], true);
- }
- }
- public function testExecute()
- {
- $this->tester->execute(
- [
- 'source' => BP . '/dev/tests/integration/testsuite/Magento/Setup/Console/Command/_files/i18n.csv',
- 'locale' => 'de_DE',
- '--allow-duplicates' => true,
- ]
- );
- $this->assertEquals('Successfully saved de_DE language package.' . PHP_EOL, $this->tester->getDisplay());
- $basePath = BP . '/dev/tests/integration/testsuite/Magento/Setup/Console/Command/_files/root/app/code';
- $this->assertFileExists($basePath . '/Magento/A/i18n/de_DE.csv');
- $this->assertFileExists($basePath . '/Magento/B/i18n/de_DE.csv');
- $this->assertFileExists($basePath . '/Magento/C/i18n/de_DE.csv');
- $this->assertFileExists($basePath . '/Magento/D/i18n/de_DE.csv');
- }
- /**
- * @expectedException \InvalidArgumentException
- * @expectedExceptionMessage Cannot open dictionary file:
- */
- public function testExecuteNonExistingPath()
- {
- $nonExistPath = BP . '/dev/tests/integration/testsuite/Magento/Setup/Console/Command/_files/non_exist.csv';
- $this->tester->execute(
- [
- 'source' => $nonExistPath,
- 'locale' => 'de_DE',
- '--allow-duplicates' => true,
- ]
- );
- }
- /**
- * @expectedException \InvalidArgumentException
- * @expectedExceptionMessage Possible values for 'mode' option are 'replace' and 'merge'
- */
- public function testExecuteInvalidMode()
- {
- $this->tester->execute(
- [
- 'source' => BP . '/dev/tests/integration/testsuite/Magento/Setup/Console/Command/_files/i18n.csv',
- 'locale' => 'de_DE',
- '--allow-duplicates' => true,
- '--mode' => 'invalid'
- ]
- );
- }
- }
|