MongoConnectorTest   A
last analyzed

Complexity

Total Complexity 1

Size/Duplication

Total Lines 24
Duplicated Lines 0 %

Coupling/Cohesion

Components 0
Dependencies 2

Importance

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

1 Method

Rating   Name   Duplication   Size   Complexity  
A testConnect() 0 18 1
1
<?php
2
3
namespace SfCod\QueueBundle\Tests\Connector;
4
5
use PHPUnit\Framework\TestCase;
6
use SfCod\QueueBundle\Base\JobResolverInterface;
7
use SfCod\QueueBundle\Connector\MongoConnector;
8
use SfCod\QueueBundle\Queue\MongoQueue;
9
use SfCod\QueueBundle\Service\MongoDriver;
10
11
/**
12
 * Class MongoConnectorTest
13
 *
14
 * @author Virchenko Maksim <[email protected]>
15
 *
16
 * @package SfCod\QueueBundle\Tests\Connector
17
 */
18
class MongoConnectorTest extends TestCase
19
{
20
    /**
21
     * Test connect
22
     */
23
    public function testConnect()
24
    {
25
        $jobResolver = $this->createMock(JobResolverInterface::class);
26
        $mongoDriver = $this->createMock(MongoDriver::class);
27
28
        $connector = new MongoConnector($jobResolver, $mongoDriver);
0 ignored issues
show
Documentation introduced by
$jobResolver is of type object<PHPUnit\Framework\MockObject\MockObject>, but the function expects a object<SfCod\QueueBundle...e\JobResolverInterface>.

It seems like the type of the argument is not accepted by the function/method which you are calling.

In some cases, in particular if PHP’s automatic type-juggling kicks in this might be fine. In other cases, however this might be a bug.

We suggest to add an explicit type cast like in the following example:

function acceptsInteger($int) { }

$x = '123'; // string "123"

// Instead of
acceptsInteger($x);

// we recommend to use
acceptsInteger((integer) $x);
Loading history...
Documentation introduced by
$mongoDriver is of type object<PHPUnit\Framework\MockObject\MockObject>, but the function expects a object<SfCod\QueueBundle\Service\MongoDriver>.

It seems like the type of the argument is not accepted by the function/method which you are calling.

In some cases, in particular if PHP’s automatic type-juggling kicks in this might be fine. In other cases, however this might be a bug.

We suggest to add an explicit type cast like in the following example:

function acceptsInteger($int) { }

$x = '123'; // string "123"

// Instead of
acceptsInteger($x);

// we recommend to use
acceptsInteger((integer) $x);
Loading history...
29
30
        $config = [
31
            'collection' => uniqid('collection_'),
32
            'queue' => uniqid('queue_'),
33
            'expire' => rand(1, 1000),
34
            'limit' => rand(1, 10),
35
        ];
36
37
        $queue = $connector->connect($config);
38
39
        self::assertInstanceOf(MongoQueue::class, $queue);
40
    }
41
}
42