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

AbstractCommandTest   A

Complexity

Total Complexity 3

Size/Duplication

Total Lines 39
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 5
Metric Value
wmc 3
lcom 1
cbo 5
dl 0
loc 39
rs 10

3 Methods

Rating   Name   Duplication   Size   Complexity  
A setUp() 0 11 1
A tearDown() 0 4 1
A getCommandBus() 0 4 1
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