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 joseph
26:39
created

itCanBulkCreateSimpleEntities()

Size

Total Lines 36
Code Lines 14

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
eloc 14
nc 1
nop 0
dl 0
loc 36
c 0
b 0
f 0

3 Methods

Rating   Name   Duplication   Size   Complexity  
A BulkSimpleEntityCreatorTest.php$0 ➔ getTableName() 0 3 1
A BulkSimpleEntityCreatorTest.php$0 ➔ getEntityFqn() 0 3 1
A BulkSimpleEntityCreatorTest.php$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
     * @var BulkSimpleEntityCreator
21
     */
22
    private $creator;
23
24
    /**
25
     * @var string
26
     */
27
    private $testEntityFqn;
28
29
    public function setup()
30
    {
31
        parent::setUp();
32
        $this->generateTestCode();
33
        $this->setupCopiedWorkDirAndCreateDatabase();
34
        $this->creator = $this->container->get(BulkSimpleEntityCreator::class);
35
        $this->testEntityFqn = $this->getCopiedFqn(self::TEST_ENTITY);
36
    }
37
38
    /**
39
     * @test
40
     * @throws \EdmondsCommerce\DoctrineStaticMeta\Exception\DoctrineStaticMetaException
41
     */
42
    public function itCanBulkCreateSimpleEntities(): void
43
    {
44
        $tableName = $this->getEntityManager()->getClassMetadata($this->testEntityFqn)->getTableName();
45
        $this->creator->setHelper(new class($tableName, $this->testEntityFqn) implements BulkSimpleEntityCreatorHelper
46
        {
47
            /**
48
             * @var string
49
             */
50
            private $tableName;
51
            /**
52
             * @var string
53
             */
54
            private $entityFqn;
55
56
            public function __construct(string $tableName, string $entityFqn)
57
            {
58
                $this->tableName = $tableName;
59
                $this->entityFqn = $entityFqn;
60
            }
61
62
            public function getTableName(): string
63
            {
64
                return $this->tableName;
65
            }
66
67
            public function getEntityFqn(): string
68
            {
69
                return $this->entityFqn;
70
            }
71
        });
72
        $num = 10000;
73
        $this->creator->startBulkProcess();
74
        $this->creator->addEntitiesToSave($this->getArrayOfEntityDatas($num));
75
        $this->creator->endBulkProcess();
76
        $loaded = $this->getRepositoryFactory()->getRepository($this->testEntityFqn)->findAll();
77
        self::assertCount($num, $loaded);
78
    }
79
80
    private function getArrayOfEntityDatas($num): array
81
    {
82
        $return = [];
83
        foreach (range(1, $num) as $key) {
84
            $return[$key] = $this->getBulkEntityData($key);
85
        }
86
87
        return $return;
88
    }
89
90
    private function getBulkEntityData(int $key): array
91
    {
92
        return [
93
            'string' => md5('key:' . $key),
94
        ];
95
    }
96
}
97