Completed
Push — 3.x ( 3a82e5...0238da )
by Grégoire
01:26
created

ModelManagerTest::getWrongDocuments()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 10

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
dl 0
loc 10
rs 9.9332
c 0
b 0
f 0
cc 1
nc 1
nop 0
1
<?php
2
3
declare(strict_types=1);
4
5
/*
6
 * This file is part of the Sonata Project package.
7
 *
8
 * (c) Thomas Rabaix <[email protected]>
9
 *
10
 * For the full copyright and license information, please view the LICENSE
11
 * file that was distributed with this source code.
12
 */
13
14
namespace Sonata\DoctrineMongoDBAdminBundle\Tests\Model;
15
16
use PHPUnit\Framework\TestCase;
17
use Sonata\DoctrineMongoDBAdminBundle\Model\ModelManager;
18
use Symfony\Bridge\Doctrine\ManagerRegistry;
19
20
class ModelManagerTest extends TestCase
21
{
22
    public function testFilterEmpty(): void
23
    {
24
        $registry = $this->createMock(ManagerRegistry::class);
25
26
        new ModelManager($registry);
27
    }
28
29
    /**
30
     * @dataProvider getWrongDocuments
31
     *
32
     * @param mixed $document
33
     */
34
    public function testNormalizedIdentifierException($document): void
35
    {
36
        $registry = $this->createMock(ManagerRegistry::class);
37
38
        $model = new ModelManager($registry);
39
40
        $this->expectException(\RuntimeException::class);
41
42
        $model->getNormalizedIdentifier($document);
43
    }
44
45
    public function getWrongDocuments(): iterable
46
    {
47
        yield [0];
48
        yield [1];
49
        yield [false];
50
        yield [true];
51
        yield [[]];
52
        yield [''];
53
        yield ['sonata-project'];
54
    }
55
56
    public function testGetNormalizedIdentifierNull(): void
57
    {
58
        $registry = $this->createMock(ManagerRegistry::class);
59
60
        $model = new ModelManager($registry);
61
62
        $this->assertNull($model->getNormalizedIdentifier(null));
0 ignored issues
show
Documentation introduced by
null is of type null, but the function expects a object.

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...
63
    }
64
}
65