Passed
Push — master ( de7f73...ce1374 )
by Sébastien
01:04 queued 12s
created

BdfQueueBundleTest::test_destination_options()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 10
Code Lines 6

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
cc 1
eloc 6
c 1
b 0
f 0
nc 1
nop 0
dl 0
loc 10
rs 10
1
<?php
2
3
namespace Bdf\QueueBundle\Tests;
4
5
require_once __DIR__.'/TestKernel.php';
6
7
use Bdf\Queue\Console\Command\BindCommand;
8
use Bdf\Queue\Console\Command\ConsumeCommand;
9
use Bdf\Queue\Console\Command\Failer\DeleteCommand;
10
use Bdf\Queue\Console\Command\Failer\FlushCommand;
11
use Bdf\Queue\Console\Command\Failer\ForgetCommand;
12
use Bdf\Queue\Console\Command\Failer\RetryCommand;
13
use Bdf\Queue\Console\Command\Failer\ShowCommand;
14
use Bdf\Queue\Console\Command\InfoCommand;
15
use Bdf\Queue\Console\Command\ProduceCommand;
16
use Bdf\Queue\Console\Command\SetupCommand;
17
use Bdf\Queue\Destination\DestinationInterface;
18
use Bdf\Queue\Destination\DestinationManager;
19
use Bdf\QueueBundle\BdfQueueBundle;
20
use PHPUnit\Framework\TestCase;
21
use Symfony\Bundle\FrameworkBundle\Console\Application;
22
use Symfony\Component\DependencyInjection\ContainerBuilder;
23
24
/**
25
 * BdfSerializerBundleTest
26
 */
27
class BdfQueueBundleTest extends TestCase
28
{
29
    public function test_default_config()
30
    {
31
        $builder = $this->createMock(ContainerBuilder::class);
32
33
        $bundle = new BdfQueueBundle();
34
35
        $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...
36
    }
37
38
    /**
39
     *
40
     */
41
    public function test_kernel()
42
    {
43
        $kernel = new \TestKernel('dev', true);
44
        $kernel->boot();
45
46
        $this->assertInstanceOf(DestinationManager::class, $kernel->getContainer()->get('bdf_queue.destination_manager'));
47
        $this->assertSame($kernel->getContainer()->get('bdf_queue.destination_manager'), $kernel->getContainer()->get(DestinationManager::class));
48
    }
49
50
    /**
51
     *
52
     */
53
    public function test_functional()
54
    {
55
        $kernel = new \TestKernel('dev', true);
56
        $kernel->boot();
57
58
        /** @var DestinationManager $destinations */
59
        $destinations = $kernel->getContainer()->get('bdf_queue.destination_manager');
60
        $destination = $destinations->create('b2p_bus');
61
62
        $this->assertInstanceOf(DestinationInterface::class, $destination);
63
    }
64
65
    /**
66
     *
67
     */
68
    public function test_connection_options()
69
    {
70
        $kernel = new \TestKernel('dev', true);
71
        $kernel->boot();
72
73
        $configs = $kernel->getContainer()->getParameter('bdf_queue.connections');
74
75
        $this->assertEquals([
76
            'gearman' => [
77
                'driver' => null,
78
                'host' => null,
79
                'serializer' => ['id' => 'native'],
80
                'queue' => null,
81
                'url' => 'gearman://127.0.0.1',
82
                'options' => ['client_timeout' => 1],
83
                'vendor' => null,
84
                'port' => null,
85
                'user' => null,
86
                'password' => null,
87
                'connection_factory' => null,
88
            ]
89
        ], $configs);
90
    }
91
92
    /**
93
     *
94
     */
95
    public function test_destination_options()
96
    {
97
        $kernel = new \TestKernel('dev', true);
98
        $kernel->boot();
99
100
        $configs = $kernel->getContainer()->getParameter('bdf_queue.destinations');
101
102
        $this->assertEquals([
103
            'b2p_bus' => 'queue://gearman/b2p_bus'
104
        ], $configs);
105
    }
106
107
    /**
108
     *
109
     */
110
    public function test_commands()
111
    {
112
        $kernel = new \TestKernel('dev', true);
113
        $kernel->boot();
114
        $console = new Application($kernel);
115
116
        $this->assertInstanceOf(BindCommand::class, $console->get('queue:bind'));
117
        $this->assertInstanceOf(ConsumeCommand::class, $console->get('queue:consume'));
118
        $this->assertInstanceOf(InfoCommand::class, $console->get('queue:info'));
119
        $this->assertInstanceOf(ProduceCommand::class, $console->get('queue:produce'));
120
        $this->assertInstanceOf(SetupCommand::class, $console->get('queue:setup'));
121
122
        $this->assertInstanceOf(DeleteCommand::class, $console->get('queue:failer:delete'));
123
        $this->assertInstanceOf(RetryCommand::class, $console->get('queue:failer:retry'));
124
        $this->assertInstanceOf(ShowCommand::class, $console->get('queue:failer:show'));
125
        $this->assertInstanceOf(FlushCommand::class, $console->get('queue:failer:flush'));
126
        $this->assertInstanceOf(ForgetCommand::class, $console->get('queue:failer:forget'));
127
    }
128
}
129