Passed
Push — master ( ccac05...2a0bbc )
by Kevin
02:22
created

PropertyTest::setUp()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 5
Code Lines 3

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
eloc 3
c 1
b 0
f 0
dl 0
loc 5
rs 10
cc 1
nc 1
nop 0
1
<?php
2
3
namespace Zenstruck\Foundry\Tests\Functional\Bundle\Extractor;
4
5
use Symfony\Bundle\FrameworkBundle\Test\KernelTestCase;
6
use Zenstruck\Foundry\Bundle\Extractor\DoctrineTypes;
7
use Zenstruck\Foundry\Bundle\Extractor\Property;
8
9
class PropertyTest extends KernelTestCase
10
{
11
    /**
12
     * @var Property|object|null
13
     */
14
    private $property;
15
16
    protected function setUp(): void
17
    {
18
        self::bootKernel();
19
        $em = static::$container->get('doctrine.orm.default_entity_manager');
20
        $this->property = new Property($em);
0 ignored issues
show
Bug introduced by
It seems like $em can also be of type null; however, parameter $em of Zenstruck\Foundry\Bundle...Property::__construct() does only seem to accept Doctrine\ORM\EntityManagerInterface, maybe add an additional type check? ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-type  annotation

20
        $this->property = new Property(/** @scrutinizer ignore-type */ $em);
Loading history...
21
    }
22
23
    /**
24
     * @test
25
     * @dataProvider doctrineTypes
26
     */
27
    public function generated_faker_method(string $doctrineType)
28
    {
29
        $createdFakerMethodAsString = $this->property->createFakerMethodFromDoctrineType($doctrineType);
0 ignored issues
show
Bug introduced by
The method createFakerMethodFromDoctrineType() does not exist on null. ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-call  annotation

29
        /** @scrutinizer ignore-call */ 
30
        $createdFakerMethodAsString = $this->property->createFakerMethodFromDoctrineType($doctrineType);

This check looks for calls to methods that do not seem to exist on a given type. It looks for the method on the type itself as well as in inherited classes or implemented interfaces.

This is most likely a typographical error or the method has been renamed.

Loading history...
30
31
        $this->assertEquals(DoctrineTypes::DOCTRINE_TYPES[$doctrineType], $createdFakerMethodAsString);
32
    }
33
34
    public function doctrineTypes()
35
    {
36
        return [
37
            ['ARRAY'],
38
            ['ASCII_STRING'],
39
            ['BIGINT'],
40
            ['BLOB'],
41
            ['BOOLEAN'],
42
            ['DATE_MUTABLE'],
43
            ['DATE_IMMUTABLE'],
44
            ['DATETIME_MUTABLE'],
45
            ['DATETIME_IMMUTABLE'],
46
            ['DATETIMETZ_MUTABLE'],
47
            ['DATETIMETZ_IMMUTABLE'],
48
            ['DECIMAL'],
49
            ['FLOAT'],
50
            ['INTEGER'],
51
            ['JSON'],
52
            ['JSON_ARRAY'],
53
            ['SIMPLE_ARRAY'],
54
            ['SMALLINT'],
55
            ['STRING'],
56
            ['TEXT'],
57
            ['TIME_MUTABLE'],
58
            ['TIME_IMMUTABLE'],
59
        ];
60
    }
61
}
62