DoctrineSpecificationBundleTest   A
last analyzed

Complexity

Total Complexity 2

Size/Duplication

Total Lines 23
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 4

Importance

Changes 2
Bugs 0 Features 0
Metric Value
wmc 2
c 2
b 0
f 0
lcom 1
cbo 4
dl 0
loc 23
rs 10

2 Methods

Rating   Name   Duplication   Size   Complexity  
A testConstruct() 0 7 1
A testBuildAddCompilerPass() 0 12 1
1
<?php
2
3
namespace Tests\GBProd\DoctrineSpecificationBundle;
4
5
use GBProd\DoctrineSpecificationBundle\DependencyInjection\Compiler\QueryFactoryPass;
6
use GBProd\DoctrineSpecificationBundle\DoctrineSpecificationBundle;
7
use PHPUnit\Framework\TestCase;
8
use Symfony\Component\DependencyInjection\ContainerBuilder;
9
use Symfony\Component\HttpKernel\Bundle\Bundle;
10
11
/**
12
 * Tests for Bundle
13
 *
14
 * @author gbprod <[email protected]>
15
 */
16
class DoctrineSpecificationBundleTest extends TestCase
17
{
18
    public function testConstruct()
19
    {
20
        $bundle = new DoctrineSpecificationBundle();
21
22
        $this->assertInstanceOf(Bundle::class, $bundle);
23
        $this->assertInstanceOf(DoctrineSpecificationBundle::class, $bundle);
24
    }
25
26
    public function testBuildAddCompilerPass()
27
    {
28
        $container = $this->createMock(ContainerBuilder::class);
29
        $container
30
            ->expects($this->once())
31
            ->method('addCompilerPass')
32
            ->with($this->isInstanceOf(QueryFactoryPass::class))
33
        ;
34
35
        $bundle = new DoctrineSpecificationBundle();
36
        $bundle->build($container);
0 ignored issues
show
Documentation introduced by
$container is of type object<PHPUnit\Framework\MockObject\MockObject>, but the function expects a object<Symfony\Component...ction\ContainerBuilder>.

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...
37
    }
38
}
39