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 (#101)
by joseph
18:59
created

EntitySaverLargeTest   A

Complexity

Total Complexity 12

Size/Duplication

Total Lines 80
Duplicated Lines 0 %

Importance

Changes 0
Metric Value
wmc 12
eloc 51
dl 0
loc 80
rs 10
c 0
b 0
f 0

4 Methods

Rating   Name   Duplication   Size   Complexity  
A setup() 0 15 4
B testItCanSaveAndRemoveMultipleEntities() 0 27 6
A testItCanSaveAndRemoveASingleEntity() 0 13 1
A findAllEntity() 0 5 1
1
<?php declare(strict_types=1);
2
3
namespace EdmondsCommerce\DoctrineStaticMeta\Tests\Large\Entity\Savers;
4
5
use EdmondsCommerce\DoctrineStaticMeta\MappingHelper;
6
use EdmondsCommerce\DoctrineStaticMeta\Tests\Assets\AbstractLargeTest;
7
use EdmondsCommerce\DoctrineStaticMeta\Tests\Assets\AbstractTest;
8
9
/**
10
 * @large
11
 */
12
class EntitySaverLargeTest extends AbstractLargeTest
13
{
14
    public const WORK_DIR = AbstractTest::VAR_PATH . '/' . self::TEST_TYPE_LARGE . '/EntitySaverLargeTest';
15
16
    private const TEST_ENTITIES = [
17
        self::TEST_PROJECT_ROOT_NAMESPACE . '\\Entities\\EntitySaverLargeTestEntityOne',
18
        self::TEST_PROJECT_ROOT_NAMESPACE . '\\Entities\\Deeply\\Nested\\EntitySaverLargeTestEntityTwo',
19
    ];
20
21
    private const TEST_FIELDS = [
22
        self::TEST_PROJECT_ROOT_NAMESPACE . '\\Entity\\Fields\\Traits\\NameFieldTrait',
23
        self::TEST_PROJECT_ROOT_NAMESPACE . '\\Entity\\Fields\\Traits\\FooFieldTrait',
24
    ];
25
26
    public function setup()
27
    {
28
        parent::setup();
29
        $fieldGenerator = $this->getFieldGenerator();
30
        foreach (self::TEST_FIELDS as $fieldFqn) {
31
            $fieldGenerator->generateField($fieldFqn, MappingHelper::TYPE_STRING);
32
        }
33
        $entityGenerator = $this->getEntityGenerator();
34
        foreach (self::TEST_ENTITIES as $entityFqn) {
35
            $entityGenerator->generateEntity($entityFqn);
36
            foreach (self::TEST_FIELDS as $fieldFqn) {
37
                $this->getFieldSetter()->setEntityHasField($entityFqn, $fieldFqn);
38
            }
39
        }
40
        $this->setupCopiedWorkDirAndCreateDatabase();
41
    }
42
43
    public function testItCanSaveAndRemoveASingleEntity(): void
44
    {
45
        $entityFqn = $this->getCopiedFqn(current(self::TEST_ENTITIES));
46
        $entity    = $this->createEntity($entityFqn);
47
        $entity->setName('blah');
0 ignored issues
show
Bug introduced by
The method setName() does not exist on EdmondsCommerce\Doctrine...erfaces\EntityInterface. ( Ignorable by Annotation )

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

47
        $entity->/** @scrutinizer ignore-call */ 
48
                 setName('blah');

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...
48
        $entity->setfoo('bar');
0 ignored issues
show
Bug introduced by
The method setfoo() does not exist on EdmondsCommerce\Doctrine...erfaces\EntityInterface. ( Ignorable by Annotation )

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

48
        $entity->/** @scrutinizer ignore-call */ 
49
                 setfoo('bar');

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...
49
        $saver = $this->getEntitySaver();
50
        $saver->save($entity);
51
        $loaded = $this->findAllEntity($entityFqn)[0];
52
        self::assertSame($entity->getName(), $loaded->getName());
0 ignored issues
show
Bug introduced by
The method getName() does not exist on EdmondsCommerce\Doctrine...erfaces\EntityInterface. ( Ignorable by Annotation )

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

52
        self::assertSame($entity->/** @scrutinizer ignore-call */ getName(), $loaded->getName());

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...
53
        self::assertSame($entity->getFoo(), $loaded->getFoo());
0 ignored issues
show
Bug introduced by
The method getFoo() does not exist on EdmondsCommerce\Doctrine...erfaces\EntityInterface. ( Ignorable by Annotation )

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

53
        self::assertSame($entity->/** @scrutinizer ignore-call */ getFoo(), $loaded->getFoo());

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...
54
        $saver->remove($loaded);
55
        self::assertSame([], $this->findAllEntity($entityFqn));
56
    }
57
58
    protected function findAllEntity(string $entityFqn): array
59
    {
60
        $entityManager = $this->getEntityManager();
61
62
        return $entityManager->getRepository($entityFqn)->findAll();
63
    }
64
65
    public function testItCanSaveAndRemoveMultipleEntities(): void
66
    {
67
        $entities = [];
68
        foreach (self::TEST_ENTITIES as $entityFqn) {
69
            $entityFqn = $this->getCopiedFqn($entityFqn);
70
            foreach (range(0, 9) as $num) {
71
                $entities[$entityFqn . $num] = $this->createEntity($entityFqn);
72
                $entities[$entityFqn . $num]->setName('blah');
73
                $entities[$entityFqn . $num]->setfoo('bar');
74
            }
75
        }
76
        $saver = $this->getEntitySaver();
77
        $saver->saveAll($entities);
78
        foreach (self::TEST_ENTITIES as $entityFqn) {
79
            $entityFqn = $this->getCopiedFqn($entityFqn);
80
            $loaded    = $this->findAllEntity($entityFqn);
81
            self::assertCount(10, $loaded);
82
            foreach (range(0, 9) as $num) {
83
                self::assertSame($entities[$entityFqn . $num]->getName(), $loaded[$num]->getName());
84
                self::assertSame($entities[$entityFqn . $num]->getFoo(), $loaded[$num]->getFoo());
85
            }
86
        }
87
88
        $saver->removeAll($entities);
89
        foreach (self::TEST_ENTITIES as $entityFqn) {
90
            $entityFqn = $this->getCopiedFqn($entityFqn);
91
            self::assertSame([], $this->findAllEntity($entityFqn));
92
        }
93
    }
94
}
95