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::setup()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 6
Code Lines 4

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
cc 1
eloc 4
nc 1
nop 0
dl 0
loc 6
rs 10
c 0
b 0
f 0
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
}