GitHub Access Token became invalid

It seems like the GitHub access token used for retrieving details about this repository from GitHub became invalid. This might prevent certain types of inspections from being run (in particular, everything related to pull requests).
Please ask an admin of your repository to re-new the access token on this website.
Completed
Push — master ( 01d72f...5182b7 )
by Dominic
04:33
created

ExportCommandTest::testExportWithWrongArguments()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 11
Code Lines 7

Duplication

Lines 11
Ratio 100 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
dl 11
loc 11
rs 9.4285
c 1
b 0
f 0
cc 1
eloc 7
nc 1
nop 0
1
<?php
2
3
namespace EllipseSynergie\LocaleToYaml\Tests\Commands;
4
5
use EllipseSynergie\LocaleToYaml\Commands\ExportCommand;
6
use Symfony\Component\Console\Tester\CommandTester;
7
use Symfony\Component\Console\Application;
8
9
/**
10
 * Class ExportCommandTest
11
 *
12
 * @package EllipseSynergie\ApiResponse\Tests
13
 * @author Dominic Martineau <[email protected]>
14
 */
15
class ExportCommandTest extends \PHPUnit_Framework_TestCase
16
{
17
    public function testExportSucceed()
18
    {
19
        $application = new Application();
20
        $application->add(new ExportCommand());
21
22
        $command = $application->find('lang:export-to-yaml');
23
        $commandTester = new CommandTester($command);
24
        $commandTester->execute(array(
25
            'command'  => $command->getName(),
26
            'in' => 'tests/locale.php'
27
        ));
28
29
        // the output of the command in the console
30
        $output = $commandTester->getDisplay();
31
        $this->assertContains('Exporting tests/locale.php to tests/locale.yaml', $output);
32
33
        // validate content
34
        $content = "foo: bar\n" .
35
            "hello:\n" .
36
            "    world: 'Hello world!'\n" .
37
            "    number: 666\n" .
38
            "    three:\n" .
39
            "        four: five\n" .
40
            "    multi: |\n" .
41
            "        This is a\n" .
42
            "        multi line\n" .
43
            "        sentence.\n";
44
        $this->assertSame($content, file_get_contents('tests/locale.yaml'));
45
46
        // remove outputed file
47
        @unlink('tests/locale.yaml');
0 ignored issues
show
Security Best Practice introduced by
It seems like you do not handle an error condition here. This can introduce security issues, and is generally not recommended.

If you suppress an error, we recommend checking for the error condition explicitly:

// For example instead of
@mkdir($dir);

// Better use
if (@mkdir($dir) === false) {
    throw new \RuntimeException('The directory '.$dir.' could not be created.');
}
Loading history...
48
    }
49
50
    /**
51
     * @expectedException \Symfony\Component\Console\Exception\RuntimeException
52
     */
53 View Code Duplication
    public function testExportWithWrongArguments()
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...
54
    {
55
        $application = new Application();
56
        $application->add(new ExportCommand());
57
58
        $command = $application->find('lang:export-to-yaml');
59
        $commandTester = new CommandTester($command);
60
        $commandTester->execute(array(
61
            'command'  => $command->getName(),
62
        ));
63
    }
64
65
    /**
66
     * @expectedException \EllipseSynergie\LocaleToYaml\Exceptions\FileNotFoundException
67
     */
68 View Code Duplication
    public function testExportWithInvalidFilename()
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...
69
    {
70
        $application = new Application();
71
        $application->add(new ExportCommand());
72
73
        $command = $application->find('lang:export-to-yaml');
74
        $commandTester = new CommandTester($command);
75
        $commandTester->execute(array(
76
            'command'  => $command->getName(),
77
            'in' => 'tests/foo.php'
78
        ));
79
    }
80
}
81