Completed
Branch v1.x-dev (5736e4)
by Benjamin
04:09
created

RulesLoaderTest::testExecute()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 9
Code Lines 5

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
cc 1
eloc 5
c 0
b 0
f 0
nc 1
nop 0
dl 0
loc 9
rs 10
1
<?php
2
3
namespace Obblm\Core\Tests\Command;
4
5
use Symfony\Bundle\FrameworkBundle\Console\Application;
6
use Symfony\Bundle\FrameworkBundle\Test\KernelTestCase;
7
use Symfony\Component\Console\Tester\CommandTester;
8
9
class RulesLoaderTest extends KernelTestCase
10
{
11
    protected $application;
12
13
    protected function setUp(): void
14
    {
15
        self::bootKernel();
16
        $this->application = new Application(self::$kernel);
17
        $command = $this->application->find('doctrine:database:create');
18
        $commandTester = new CommandTester($command);
19
        $commandTester->execute([]);
20
        $command = $this->application->find('doctrine:schema:update');
21
        $commandTester = new CommandTester($command);
22
        $commandTester->execute([
23
            'command' => $command->getName(),
24
            '--force' => true
25
        ]);
26
    }
27
28
    public function testExecute()
29
    {
30
        $command = $this->application->find('obblm:rules:load');
31
        $commandTester = new CommandTester($command);
32
        $commandTester->execute([]);
33
34
        $output = $commandTester->getDisplay();
35
        // the output of the command in the console
36
        $this->assertStringContainsString('[OK] All rules have been created or updated.', $output);
37
    }
38
39
    protected function tearDown(): void
40
    {
41
        parent::tearDown();
42
43
        // doing this is recommended to avoid memory leaks
44
        $this->application = null;
45
    }
46
}
47