Passed
Pull Request — master (#173)
by
unknown
02:36
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 1
Metric Value
eloc 3
c 1
b 0
f 1
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::getContainer()->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
            ['BINARY'],
41
            ['BLOB'],
42
            ['BOOLEAN'],
43
            ['DATE_MUTABLE'],
44
            ['DATE_IMMUTABLE'],
45
            ['DATEINTERVAL'],
46
            ['DATETIME_MUTABLE'],
47
            ['DATETIME_IMMUTABLE'],
48
            ['DATETIMETZ_MUTABLE'],
49
            ['DATETIMETZ_IMMUTABLE'],
50
            ['DECIMAL'],
51
            ['FLOAT'],
52
            ['GUID'],
53
            ['INTEGER'],
54
            ['JSON'],
55
            ['JSON_ARRAY'],
56
            ['OBJECT'],
57
            ['SIMPLE_ARRAY'],
58
            ['SMALLINT'],
59
            ['STRING'],
60
            ['TEXT'],
61
            ['TIME_MUTABLE'],
62
            ['TIME_IMMUTABLE'],
63
        ];
64
    }
65
}
66