Completed
Push — master ( 80ea1a...1b2f71 )
by Alejandro
01:10
created

exceptionIsThrownIfStandardConfigIsNotFound()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 5
Code Lines 3

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
c 1
b 0
f 0
dl 0
loc 5
rs 9.4285
cc 1
eloc 3
nc 1
nop 0
1
<?php
2
declare(strict_types=1);
3
4
namespace AcMailerTes\Tooling\Command;
5
6
use AcMailer\Tooling\Command\MigrateConfigCommand;
7
use AcMailer\Tooling\Exception;
8
use PHPUnit\Framework\TestCase;
9
use Symfony\Component\Console\Application;
10
use Symfony\Component\Console\Tester\CommandTester;
11
12
class MigrateConfigCommandTest extends TestCase
13
{
14
    /**
15
     * @var MigrateConfigCommand
16
     */
17
    private $command;
18
    /**
19
     * @var CommandTester
20
     */
21
    private $commandTester;
22
23
    public function setUp()
24
    {
25
        $this->command = new MigrateConfigCommand();
26
        $app = new Application();
27
        $app->add($this->command);
28
        $this->commandTester = new CommandTester($this->command);
29
    }
30
31
    /**
32
     * @test
33
     */
34
    public function configIsProperlyParsed()
35
    {
36
        $this->commandTester->execute([
37
            '--config-file' => __DIR__ . '/../../config/old_config_sample.php',
38
        ]);
39
40
        $output = $this->commandTester->getDisplay();
41
        $this->assertContains('emails', $output);
42
        $this->assertContains('mail_services', $output);
43
        $this->assertContains('\'from\' => \'[email protected]\'', $output);
44
        $this->assertContains('transport_options', $output);
45
        $this->assertContains('\'host\' => \'smtp.gmail.com\',', $output);
46
    }
47
48
    /**
49
     * @test
50
     */
51
    public function exceptionIsThrownIfProvidedConfigFilesDoesNotExist()
52
    {
53
        $this->expectException(Exception\UnexpectedValueException::class);
54
        $this->commandTester->execute([
55
            '--config-file' => 'foo',
56
        ]);
57
    }
58
59
    /**
60
     * @test
61
     */
62
    public function exceptionIsThrownIfStandardConfigIsNotFound()
63
    {
64
        $this->expectException(Exception\RuntimeException::class);
65
        $this->commandTester->execute([]);
66
    }
67
68
    /**
69
     * @test
70
     */
71
    public function exceptionIsThrownIfLoadedConfigIsEmpty()
72
    {
73
        $this->expectException(Exception\RuntimeException::class);
74
        $this->commandTester->execute([
75
            '--config-file' => __DIR__ . '/../../config/empty_config_sample.php',
76
        ]);
77
    }
78
}
79