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 (#154)
by Ross
22:04
created

BulkSimpleEntityCreatorTest   A

Complexity

Total Complexity 7

Size/Duplication

Total Lines 75
Duplicated Lines 0 %

Importance

Changes 0
Metric Value
eloc 28
dl 0
loc 75
rs 10
c 0
b 0
f 0
wmc 7

10 Methods

Rating   Name   Duplication   Size   Complexity  
itCanBulkCreateSimpleEntities() 0 36 ?
A hp$0 ➔ getBulkEntityData() 0 4 1
A hp$0 ➔ getTableName() 0 3 1
A hp$0 ➔ itCanBulkCreateSimpleEntities() 0 36 1
getBulkEntityData() 0 4 ?
A hp$0 ➔ getArrayOfEntityDatas() 0 8 2
A setup() 0 6 1
A hp$0 ➔ getEntityFqn() 0 3 1
getArrayOfEntityDatas() 0 8 ?
A hp$0 ➔ __construct() 0 4 1
1
<?php declare(strict_types=1);
2
3
namespace EdmondsCommerce\DoctrineStaticMeta\Tests\Large\D\Entity\Savers;
4
5
use EdmondsCommerce\DoctrineStaticMeta\Entity\Savers\BulkEntityUpdater\BulkSimpleEntityCreatorHelper;
6
use EdmondsCommerce\DoctrineStaticMeta\Entity\Savers\BulkSimpleEntityCreator;
7
use EdmondsCommerce\DoctrineStaticMeta\Tests\Assets\AbstractLargeTest;
8
use EdmondsCommerce\DoctrineStaticMeta\Tests\Assets\TestCodeGenerator;
9
10
/**
11
 * @large
12
 * @covers \EdmondsCommerce\DoctrineStaticMeta\Entity\Savers\BulkSimpleEntityCreator
13
 */
14
class BulkSimpleEntityCreatorTest extends AbstractLargeTest
15
{
16
    public const WORK_DIR = self::VAR_PATH . '/' . self::TEST_TYPE_LARGE . '/BulkSimpleEntityCreatorTest';
17
18
    public const TEST_ENTITY = self::TEST_ENTITIES_ROOT_NAMESPACE . TestCodeGenerator::TEST_ENTITY_SIMPLE;
19
20
    /**
21
     * @var BulkSimpleEntityCreator
22
     */
23
    private $creator;
24
25
    public function setup()
26
    {
27
        parent::setUp();
28
        $this->generateTestCode();
29
        $this->createDatabase();
30
        $this->creator = $this->container->get(BulkSimpleEntityCreator::class);
31
    }
32
33
    /**
34
     * @test
35
     * @throws \EdmondsCommerce\DoctrineStaticMeta\Exception\DoctrineStaticMetaException
36
     */
37
    public function itCanBulkCreateSimpleEntities(): void
38
    {
39
        $tableName = $this->getEntityManager()->getClassMetadata(self::TEST_ENTITY)->getTableName();
40
        $this->creator->setHelper(new class($tableName, self::TEST_ENTITY) implements BulkSimpleEntityCreatorHelper
41
        {
42
            /**
43
             * @var string
44
             */
45
            private $tableName;
46
            /**
47
             * @var string
48
             */
49
            private $entityFqn;
50
51
            public function __construct(string $tableName, string $entityFqn)
52
            {
53
                $this->tableName = $tableName;
54
                $this->entityFqn = $entityFqn;
55
            }
56
57
            public function getTableName(): string
58
            {
59
                return $this->tableName;
60
            }
61
62
            public function getEntityFqn(): string
63
            {
64
                return $this->entityFqn;
65
            }
66
        });
67
        $num = 10000;
68
        $this->creator->startBulkProcess();
69
        $this->creator->addEntitiesToSave($this->getArrayOfEntityDatas($num));
70
        $this->creator->endBulkProcess();
71
        $loaded = $this->getRepositoryFactory()->getRepository(self::TEST_ENTITY)->findAll();
72
        self::assertCount($num, $loaded);
73
    }
74
75
    private function getArrayOfEntityDatas($num): array
76
    {
77
        $return = [];
78
        foreach (range(1, $num) as $key) {
79
            $return[$key] = $this->getBulkEntityData($key);
80
        }
81
82
        return $return;
83
    }
84
85
    private function getBulkEntityData(int $key): array
86
    {
87
        return [
88
            'string' => md5('key:' . $key),
89
        ];
90
    }
91
}