testGetContainerExtension()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 6

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
dl 0
loc 6
rs 10
c 0
b 0
f 0
cc 1
nc 1
nop 0
1
<?php
2
3
/*
4
 * (c) Christian Gripp <[email protected]>
5
 *
6
 * For the full copyright and license information, please view the LICENSE
7
 * file that was distributed with this source code.
8
 */
9
10
namespace Core23\SitemapBundle\Tests;
11
12
use Core23\SitemapBundle\Core23SitemapBundle;
13
use Core23\SitemapBundle\DependencyInjection\Compiler\SitemapCompilerPass;
14
use Core23\SitemapBundle\DependencyInjection\Core23SitemapExtension;
15
use PHPUnit\Framework\TestCase;
16
use Symfony\Component\DependencyInjection\ContainerBuilder;
17
18
final class Core23SitemapBundleTest extends TestCase
19
{
20
    public function testGetContainerExtension(): void
21
    {
22
        $bundle = new Core23SitemapBundle();
23
24
        static::assertInstanceOf(Core23SitemapExtension::class, $bundle->getContainerExtension());
25
    }
26
27
    public function testBuild(): void
28
    {
29
        $containerBuilder = $this->createMock(ContainerBuilder::class);
30
31
        $containerBuilder->expects(static::once())->method('addCompilerPass')
32
            ->with(static::isInstanceOf(SitemapCompilerPass::class))
33
        ;
34
35
        $bundle = new Core23SitemapBundle();
36
        $bundle->build($containerBuilder);
0 ignored issues
show
Documentation introduced by core23
$containerBuilder 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