AbstractCommandTest::tearDown()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 4
Code Lines 2

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
dl 0
loc 4
rs 10
c 0
b 0
f 0
cc 1
eloc 2
nc 1
nop 0
1
<?php
2
3
declare (strict_types = 1);
4
5
namespace HMLB\UserBundle\Tests\Command;
6
7
use HMLB\UserBundle\Tests\Functional\TestCommandExecutionCapabilities;
8
use HMLB\UserBundle\Tests\Functional\TestKernel;
9
use PHPUnit_Framework_TestCase;
10
use SimpleBus\Message\Bus\MessageBus;
11
use Symfony\Component\DependencyInjection\ContainerInterface;
12
13
/**
14
 * Helper class for testing command handling.
15
 *
16
 * @author Hugues Maignol <[email protected]>
17
 */
18
abstract class AbstractCommandTest extends PHPUnit_Framework_TestCase
19
{
20
    use TraceableCommandTestingCapabilities;
21
    use TestCommandExecutionCapabilities;
22
23
    /**
24
     * @var ContainerInterface
25
     */
26
    protected $container;
27
    /**
28
     * @var TestKernel
29
     */
30
    protected $kernel;
31
32
    public function setUp()
33
    {
34
        $kernel = new TestKernel('test', true);
35
        $kernel->boot();
36
37
        $this->kernel = $kernel;
38
        $this->container = $kernel->getContainer();
39
40
        $this->executeCommand('doctrine:database:create');
41
        $this->executeCommand('doctrine:schema:update', ['--force' => true]);
42
    }
43
44
    public function tearDown()
45
    {
46
        $this->executeCommand('doctrine:database:drop', ['--force' => true]);
47
    }
48
49
    /**
50
     * @return MessageBus
51
     */
52
    protected function getCommandBus(): MessageBus
53
    {
54
        return $this->container->get('command_bus');
55
    }
56
}
57