Passed
Pull Request — master (#20)
by Christophe
03:13
created

FunctionalTest::tearDownAfterClass()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 3
Code Lines 1

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
cc 1
eloc 1
c 1
b 0
f 0
nc 1
nop 0
dl 0
loc 3
rs 10
1
<?php
2
3
namespace Incenteev\TranslationCheckerBundle\Tests;
4
5
use Symfony\Bundle\FrameworkBundle\Console\Application;
6
use Symfony\Bundle\FrameworkBundle\Test\KernelTestCase;
7
use Symfony\Component\Console\Input\ArrayInput;
8
use Symfony\Component\Console\Output\NullOutput;
9
use Symfony\Component\Filesystem\Filesystem;
10
11
class FunctionalTest extends KernelTestCase
12
{
13
    public static function setUpBeforeClass()
14
    {
15
        self::deleteTmpDir();
16
    }
17
18
    public static function tearDownAfterClass()
19
    {
20
        self::deleteTmpDir();
21
    }
22
23
    /**
24
     * @dataProvider provideComparisonCases
25
     */
26
    public function testCompareCommand($locale, $valid)
27
    {
28
        self::bootKernel();
29
30
        $application = new Application(self::$kernel);
31
        $application->setAutoExit(false);
32
        $application->setCatchExceptions(false);
33
34
        $input = new ArrayInput(array('command' => 'incenteev:translation:compare', 'locale' => $locale, '-d' => array('test')));
35
        $output = new NullOutput();
36
37
        $expectedExitCode = $valid ? 0 : 1;
38
39
        $this->assertSame($expectedExitCode, $application->run($input, $output));
40
    }
41
42
    public static function provideComparisonCases()
43
    {
44
        return array(
45
            array('fr', true),
46
            array('de', false),
47
        );
48
    }
49
50
    protected static function getKernelClass()
51
    {
52
        return 'Incenteev\TranslationCheckerBundle\Tests\FixtureApp\TestKernel';
53
    }
54
55
    private static function deleteTmpDir()
56
    {
57
        if (!file_exists($dir = sys_get_temp_dir().'/incenteev_translation_checker')) {
58
            return;
59
        }
60
61
        $fs = new Filesystem();
62
        $fs->remove($dir);
63
    }
64
}
65