Test Failed
Push — master ( 2530ac...3f2955 )
by Vincent
10:10 queued 07:25
created

BdfQueueBundleTest::test_default_config()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 7
Code Lines 3

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
cc 1
eloc 3
c 1
b 0
f 0
nc 1
nop 0
dl 0
loc 7
rs 10
1
<?php
2
3
namespace Bdf\QueueBundle\Tests;
4
5
require_once __DIR__.'/TestKernel.php';
6
7
use Bdf\Queue\Destination\DestinationInterface;
8
use Bdf\Queue\Destination\DestinationManager;
9
use Bdf\QueueBundle\BdfQueueBundle;
10
use PHPUnit\Framework\TestCase;
11
use Symfony\Component\DependencyInjection\ContainerBuilder;
12
13
/**
14
 * BdfSerializerBundleTest
15
 */
16
class BdfQueueBundleTest extends TestCase
17
{
18
    public function test_default_config()
19
    {
20
        $builder = $this->createMock(ContainerBuilder::class);
21
22
        $bundle = new BdfQueueBundle();
23
24
        $this->assertNull($bundle->build($builder));
0 ignored issues
show
Bug introduced by
Are you sure the usage of $bundle->build($builder) targeting Symfony\Component\HttpKe...\Bundle\Bundle::build() seems to always return null.

This check looks for function or method calls that always return null and whose return value is used.

class A
{
    function getObject()
    {
        return null;
    }

}

$a = new A();
if ($a->getObject()) {

The method getObject() can return nothing but null, so it makes no sense to use the return value.

The reason is most likely that a function or method is imcomplete or has been reduced for debug purposes.

Loading history...
25
    }
26
27
    /**
28
     *
29
     */
30
    public function test_kernel()
31
    {
32
        $kernel = new \TestKernel('dev', true);
33
        $kernel->boot();
34
35
        $this->assertInstanceOf(DestinationManager::class, $kernel->getContainer()->get('bdf_queue.destination_manager'));
36
        $this->assertSame($kernel->getContainer()->get('bdf_queue.destination_manager'), $kernel->getContainer()->get(DestinationManager::class));
37
    }
38
39
    /**
40
     *
41
     */
42
    public function test_functional()
43
    {
44
        $kernel = new \TestKernel('dev', true);
45
        $kernel->boot();
46
47
        /** @var DestinationManager $destinations */
48
        $destinations = $kernel->getContainer()->get('bdf_queue.destination_manager');
49
        $destination = $destinations->create('b2p_bus');
50
51
        $this->assertInstanceOf(DestinationInterface::class, $destination);
52
    }
53
54
    /**
55
     *
56
     */
57
    public function test_connection_options()
58
    {
59
        $kernel = new \TestKernel('dev', true);
60
        $kernel->boot();
61
62
        $configs = $kernel->getContainer()->getParameter('bdf_queue.connections');
63
64
        $this->assertEquals([
65
            'gearman' => [
66
                'driver' => null,
67
                'host' => null,
68
                'serializer' => ['id' => 'native'],
69
                'queue' => null,
70
                'url' => 'gearman://127.0.0.1',
71
                'options' => ['client_timeout' => 1],
72
                'vendor' => null,
73
                'port' => null,
74
                'user' => null,
75
                'password' => null,
76
                'connection_factory' => null,
77
            ]
78
        ], $configs);
79
    }
80
81
    /**
82
     *
83
     */
84
    public function test_destination_options()
85
    {
86
        $kernel = new \TestKernel('dev', true);
87
        $kernel->boot();
88
89
        $configs = $kernel->getContainer()->getParameter('bdf_queue.destinations');
90
91
        $this->assertEquals([
92
            'b2p_bus' => 'queue://gearman/b2p_bus'
93
        ], $configs);
94
    }
95
}
96