Completed
Pull Request — master (#1)
by Pascal
12:57
created

TranslationCommandTest::setUp()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 16
Code Lines 11

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
c 1
b 0
f 0
dl 0
loc 16
rs 9.4285
cc 1
eloc 11
nc 1
nop 0
1
<?php
2
3
namespace Itkg\TranslationBundle;
4
5
use Itkg\TranslationBundle\Command\TranslationConverterCommand;
6
use Symfony\Bundle\FrameworkBundle\Console\Application;
7
use Symfony\Bundle\FrameworkBundle\Test\WebTestCase;
8
use Symfony\Component\Console\Tester\CommandTester;
9
10
/**
11
 * Class TranslationCommandTest
12
 */
13
class TranslationCommandTest extends WebTestCase
14
{
15
    private $command;
16
    private $commandTester;
17
    private $exportPath;
18
    private $importPath;
19
20
    protected function setUp()
21
    {
22
        $this->exportPath = __DIR__.'/../../export';
23
        $this->importPath =  __DIR__.'/../fixtures';
24
25
        static::$kernel = static::createKernel();
26
        static::$kernel->boot();
27
28
        $this->command     = new TranslationConverterCommand(
29
            static::$kernel->getContainer()->get('itkg_translation.finder'),
30
            static::$kernel->getContainer()->get('filesystem')
31
        );
32
        $application = new Application(static::$kernel);
33
        $this->command->setApplication($application);
34
        $this->commandTester = new CommandTester($this->command);
35
    }
36
37 View Code Duplication
    public function testExport()
0 ignored issues
show
Duplication introduced by
This method seems to be duplicated in your project.

Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation.

You can also find more detailed suggestions in the “Code” section of your repository.

Loading history...
38
    {
39
        $this->commandTester->execute(array(
40
            'command' => 'itkg_translation:translation:converter',
41
            '--input' => 'yml',
42
            '--output' => 'csv',
43
            '--path' => $this->importPath.'/data',
44
            '--output-path' => $this->exportPath
45
        ));
46
47
        $this->assertEquals(file_get_contents($this->exportPath.'/domain.en.csv'), file_get_contents($this->importPath.'/result/domain.en.csv'));
48
        $this->assertEquals(file_get_contents($this->exportPath.'/messages.fr.csv'), file_get_contents($this->importPath.'/result/messages.fr.csv'));
49
    }
50
51 View Code Duplication
    public function testImport()
0 ignored issues
show
Duplication introduced by
This method seems to be duplicated in your project.

Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation.

You can also find more detailed suggestions in the “Code” section of your repository.

Loading history...
52
    {
53
        $this->commandTester->execute(array(
54
            'command' => 'itkg_translation:translation:converter',
55
            '--input' => 'csv',
56
            '--output' => 'yml',
57
            '--path' => $this->importPath.'/data',
58
            '--output-path' => $this->exportPath
59
        ));
60
61
        $this->assertEquals(file_get_contents($this->exportPath.'/domain.en.yml'), file_get_contents($this->importPath.'/result/domain.en.yml'));
62
        $this->assertEquals(file_get_contents($this->exportPath.'/messages.fr.yml'), file_get_contents($this->importPath.'/result/messages.fr.yml'));
63
    }
64
}
65