AbstractProophAsynchronousRoutingExtensionTestCase   A
last analyzed

Complexity

Total Complexity 2

Size/Duplication

Total Lines 31
Duplicated Lines 0 %

Coupling/Cohesion

Components 0
Dependencies 2

Importance

Changes 0
Metric Value
wmc 2
lcom 0
cbo 2
dl 0
loc 31
rs 10
c 0
b 0
f 0

3 Methods

Rating   Name   Duplication   Size   Complexity  
buildContainer() 0 1 ?
A testCanCreateProducer() 0 14 1
A loadContainer() 0 11 1
1
<?php
2
3
declare(strict_types=1);
4
5
namespace TomCizek\AsynchronousRouter\Tests\DependencyInjection;
6
7
use PHPUnit\Framework\TestCase;
8
use Prooph\Bundle\ServiceBus\DependencyInjection\ProophServiceBusExtension;
9
use Symfony\Component\DependencyInjection\Compiler\CompilerPassInterface;
10
use Symfony\Component\DependencyInjection\ContainerBuilder;
11
use TomCizek\AsynchronousRouter\AsynchronousMessageProducer;
12
use TomCizek\AsynchronousRouter\DependencyInjection\ProophAsynchronousRouterExtension;
13
14
abstract class AbstractProophAsynchronousRoutingExtensionTestCase extends TestCase
15
{
16
    abstract protected function buildContainer(): TestContainerBuilder;
17
18
    public function testCanCreateProducer()
19
    {
20
        $container = $this->loadContainer('firstMessageRoute');
21
22
        $config = $container->getDefinition('prooph_asynchronous_router.firstProducer');
23
24
        self::assertEquals(AsynchronousMessageProducer::class, $config->getClass());
25
26
        /* @var $asynchronousMessageProducer AsynchronousMessageProducer */
27
28
        $asynchronousMessageProducer = $container->get('prooph_asynchronous_router.firstProducer');
29
30
        self::assertInstanceOf(AsynchronousMessageProducer::class, $asynchronousMessageProducer);
31
    }
32
33
    private function loadContainer($fixture, CompilerPassInterface ...$compilerPasses): ContainerBuilder
34
    {
35
        return $this->buildContainer()
36
            ->withExtensions(
37
                new ProophAsynchronousRouterExtension(),
38
                new ProophServiceBusExtension()
39
                )
40
            ->withConfigFiles($fixture, 'commonServices')
41
            ->withCompilerPasses(...$compilerPasses)
42
            ->compile();
43
    }
44
}
45