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 (#153)
by joseph
06:24
created

HasWeightEmbeddableTraitLargeTest   A

Complexity

Total Complexity 3

Size/Duplication

Total Lines 52
Duplicated Lines 0 %

Importance

Changes 0
Metric Value
eloc 21
dl 0
loc 52
rs 10
c 0
b 0
f 0
wmc 3

6 Methods

Rating   Name   Duplication   Size   Complexity  
A hp$0 ➔ getWeightEmbeddable() 0 5 1
itCanBeSavedAndReloadedWithTheCorrectValues() 0 20 ?
A hp$0 ➔ itCanBeSavedAndReloadedWithTheCorrectValues() 0 20 1
A hp$0 ➔ createTestEntity() 0 3 1
createTestEntity() 0 3 ?
A setUp() 0 6 1
1
<?php declare(strict_types=1);
2
3
namespace EdmondsCommerce\DoctrineStaticMeta\Tests\Large\C\Entity\Embeddable\Traits\Attribute;
4
5
use EdmondsCommerce\DoctrineStaticMeta\Entity\DataTransferObjects\AbstractEntityUpdateDto;
6
use EdmondsCommerce\DoctrineStaticMeta\Entity\Embeddable\Interfaces\Objects\Attribute\WeightEmbeddableInterface;
7
use EdmondsCommerce\DoctrineStaticMeta\Entity\Embeddable\Objects\Attribute\WeightEmbeddable;
8
use EdmondsCommerce\DoctrineStaticMeta\Entity\Interfaces\EntityInterface;
9
use EdmondsCommerce\DoctrineStaticMeta\Tests\Assets\AbstractLargeTest;
10
use EdmondsCommerce\DoctrineStaticMeta\Tests\Assets\TestCodeGenerator;
11
12
/**
13
 * @large
14
 * @covers \EdmondsCommerce\DoctrineStaticMeta\Entity\Embeddable\Traits\Attribute\HasWeightEmbeddableTrait
15
 */
16
class HasWeightEmbeddableTraitLargeTest extends AbstractLargeTest
17
{
18
    public const  WORK_DIR    = self::VAR_PATH . '/' . self::TEST_TYPE_LARGE . '/HasWeightEmbeddableTraitLargeTest';
19
    private const TEST_ENTITY = self::TEST_ENTITIES_ROOT_NAMESPACE . TestCodeGenerator::TEST_ENTITY_ALL_EMBEDDABLES;
20
    /**
21
     * @var string
22
     */
23
    private $entityFqn;
24
25
    public function setUp()
26
    {
27
        parent::setUp();
28
        $this->generateTestCode();
29
        $this->setupCopiedWorkDirAndCreateDatabase();
30
        $this->entityFqn = $this->getCopiedFqn(self::TEST_ENTITY);
31
    }
32
33
    /**
34
     * @test
35
     * @throws \EdmondsCommerce\DoctrineStaticMeta\Exception\DoctrineStaticMetaException
36
     * @throws \ReflectionException
37
     */
38
    public function itCanBeSavedAndReloadedWithTheCorrectValues()
39
    {
40
        $entity = $this->createTestEntity();
41
        $entity->update(new class($this->getCopiedFqn(self::TEST_ENTITY), $entity->getId())
42
            extends AbstractEntityUpdateDto
43
        {
44
            public function getWeightEmbeddable(): WeightEmbeddableInterface
45
            {
46
                return new WeightEmbeddable(
47
                    WeightEmbeddableInterface::UNIT_GRAM,
48
                    100
49
                );
50
            }
51
        });
52
        $this->getEntitySaver()->save($entity);
53
        $loaded                 =
54
            $this->getRepositoryFactory()->getRepository($this->getCopiedFqn(self::TEST_ENTITY))->findAll()[0];
55
        $loadedWeightEmbeddable = $loaded->getWeightEmbeddable();
56
        self::assertSame(WeightEmbeddableInterface::UNIT_GRAM, $loadedWeightEmbeddable->getUnit());
57
        self::assertSame(100.0, $loadedWeightEmbeddable->getValue());
58
    }
59
60
    /**
61
     * @return EntityInterface
62
     * @throws \EdmondsCommerce\DoctrineStaticMeta\Exception\DoctrineStaticMetaException
63
     * @throws \ReflectionException
64
     */
65
    private function createTestEntity(): EntityInterface
66
    {
67
        return $this->createEntity($this->getCopiedFqn(self::TEST_ENTITY));
68
    }
69
70
}