Completed
Push — master ( 351bd6...f43dc3 )
by Hugues
02:12
created

AbstractCommandTest::getCommandBus()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 4
Code Lines 2

Duplication

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