GitHub Access Token became invalid

It seems like the GitHub access token used for retrieving details about this repository from GitHub became invalid. This might prevent certain types of inspections from being run (in particular, everything related to pull requests).
Please ask an admin of your repository to re-new the access token on this website.
Completed
Pull Request — master (#152)
by joseph
17:58
created

ProxiesTest   A

Complexity

Total Complexity 7

Size/Duplication

Total Lines 108
Duplicated Lines 0 %

Importance

Changes 0
Metric Value
eloc 67
dl 0
loc 108
rs 10
c 0
b 0
f 0
wmc 7

5 Methods

Rating   Name   Duplication   Size   Complexity  
A proxyObjectsCanGetGettersAndSetters() 0 37 1
A getClassMetaDatas() 0 9 2
A setupProxyFactory() 0 8 1
A getTestEntityFqns() 0 9 1
A setup() 0 15 2
1
<?php declare(strict_types=1);
2
3
namespace EdmondsCommerce\DoctrineStaticMeta\Tests\Large\A;
4
5
use Doctrine\Common\Proxy\Proxy as DeprecatedProxy;
6
use Doctrine\ORM\Proxy\Proxy;
7
use Doctrine\ORM\Proxy\ProxyFactory;
8
use EdmondsCommerce\DoctrineStaticMeta\Entity\Interfaces\EntityInterface;
9
use EdmondsCommerce\DoctrineStaticMeta\Tests\Assets\AbstractLargeTest;
10
use EdmondsCommerce\DoctrineStaticMeta\Tests\Assets\AbstractTest;
11
use EdmondsCommerce\DoctrineStaticMeta\Tests\Assets\TestCodeGenerator;
12
13
/**
14
 * @coversNothing
15
 */
16
class ProxiesTest extends AbstractLargeTest
17
{
18
    public const WORK_DIR = AbstractTest::VAR_PATH . '/' . self::TEST_TYPE_MEDIUM . '/ProxiesTest/';
19
    protected static $buildOnce = true;
20
    /**
21
     * @var ProxyFactory
22
     */
23
    private $proxyFactory;
24
    /**
25
     * It is a Proxy, the others are just to make PHPStan happy
26
     *
27
     * @var Proxy|DeprecatedProxy|EntityInterface
28
     */
29
    private $proxy;
30
    private $testEntityFqns;
31
32
    public function setup()
33
    {
34
        parent::setUp();
35
        if (false === self::$built) {
36
            $this->getTestCodeGenerator()
37
                 ->copyTo(self::WORK_DIR);
38
            self::$built = true;
39
        }
40
        $this->setupCopiedWorkDirAndCreateDatabase();
41
        $this->setupProxyFactory();
42
        $this->testEntityFqns = $this->getTestEntityFqns();
43
        $this->proxyFactory->generateProxyClasses($this->getClassMetaDatas());
44
        $testEntity = current($this->testEntityFqns);
45
        $this->getEntitySaver()->save($this->createEntity($testEntity));
46
        $this->proxy = $this->proxyFactory->getProxy($testEntity, ['id' => 1]);
47
    }
48
49
    private function setupProxyFactory(): void
50
    {
51
        $proxyDir = $this->copiedWorkDir . '/proxies';
52
        mkdir($proxyDir, 0777, true);
53
        $this->proxyFactory = new ProxyFactory(
54
            $this->getEntityManager(),
55
            $proxyDir,
56
            $this->copiedRootNamespace . '\\Proxies'
57
        );
58
    }
59
60
    private function getTestEntityFqns(): array
61
    {
62
        $copiedRootNamespace = $this->copiedRootNamespace;
63
64
        return \array_map(
65
            function (string $entityFqn) use ($copiedRootNamespace): string {
66
                return $copiedRootNamespace . $entityFqn;
67
            },
68
            TestCodeGenerator::TEST_ENTITIES
69
        );
70
    }
71
72
    private function getClassMetaDatas(): array
73
    {
74
        $return        = [];
75
        $entityManager = $this->getEntityManager();
76
        foreach ($this->testEntityFqns as $entityFqn) {
77
            $return[] = $entityManager->getClassMetadata($entityFqn);
78
        }
79
80
        return $return;
81
    }
82
83
    /**
84
     * @test
85
     * @large
86
     */
87
    public function proxyObjectsCanGetGettersAndSetters(): void
88
    {
89
        $expectedSetters = [
90
            'getId'                => 'setId',
91
            'getString'            => 'setString',
92
            'getDatetime'          => 'setDatetime',
93
            'getFloat'             => 'setFloat',
94
            'getDecimal'           => 'setDecimal',
95
            'getInteger'           => 'setInteger',
96
            'getText'              => 'setText',
97
            'isBoolean'            => 'setBoolean',
98
            'getJson'              => 'setJson',
99
            'getAttributesAddress' => 'setAttributesAddress',
100
            'getAttributesEmails'  => 'setAttributesEmails',
101
            'getCompanyDirector'   => 'setCompanyDirector',
102
            'getLargeRelation'     => 'setLargeRelation',
103
        ];
104
        $actualSetters   = $this->proxy::getDoctrineStaticMeta()->getSetters();
0 ignored issues
show
Bug introduced by
The method getDoctrineStaticMeta() does not exist on Doctrine\ORM\Proxy\Proxy. ( Ignorable by Annotation )

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

104
        $actualSetters   = $this->proxy::/** @scrutinizer ignore-call */ getDoctrineStaticMeta()->getSetters();

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...
Bug introduced by
The method getDoctrineStaticMeta() does not exist on Doctrine\Common\Proxy\Proxy. ( Ignorable by Annotation )

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

104
        $actualSetters   = $this->proxy::/** @scrutinizer ignore-call */ getDoctrineStaticMeta()->getSetters();

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...
105
        self::assertSame($expectedSetters, $actualSetters);
106
        $expectedGetters = [
107
            'getId',
108
            'getUuid',
109
            'getString',
110
            'getDatetime',
111
            'getFloat',
112
            'getDecimal',
113
            'getInteger',
114
            'getText',
115
            'isBoolean',
116
            'getJson',
117
            'getAttributesAddress',
118
            'getAttributesEmails',
119
            'getCompanyDirector',
120
            'getLargeRelation',
121
        ];
122
        $actualGetters   = $this->proxy::getDoctrineStaticMeta()->getGetters();
123
        self::assertSame($expectedGetters, $actualGetters);
124
    }
125
}
126