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 (#66)
by joseph
17:35
created

EntityFactoryTest   A

Complexity

Total Complexity 5

Size/Duplication

Total Lines 70
Duplicated Lines 0 %

Importance

Changes 0
Metric Value
wmc 5
dl 0
loc 70
rs 10
c 0
b 0
f 0

4 Methods

Rating   Name   Duplication   Size   Complexity  
A itThrowsAnExceptionIfThereIsAnInvalidProperty() 0 4 1
A setup() 0 18 2
A itCanCreateAnEntityWithValues() 0 11 1
A itCanCreateAnEmptyEntity() 0 4 1
1
<?php declare(strict_types=1);
2
3
namespace EdmondsCommerce\DoctrineStaticMeta\Entity\Factory;
4
5
use EdmondsCommerce\DoctrineStaticMeta\AbstractIntegrationTest;
6
use EdmondsCommerce\DoctrineStaticMeta\Entity\Fields\Interfaces\String\EmailAddressFieldInterface;
7
use EdmondsCommerce\DoctrineStaticMeta\Entity\Fields\Interfaces\String\IsbnFieldInterface;
8
use EdmondsCommerce\DoctrineStaticMeta\Entity\Fields\Traits\String\EmailAddressFieldTrait;
9
use EdmondsCommerce\DoctrineStaticMeta\Entity\Fields\Traits\String\IsbnFieldTrait;
10
11
class EntityFactoryTest extends AbstractIntegrationTest
12
{
13
    public const WORK_DIR = AbstractIntegrationTest::VAR_PATH.'/'.self::TEST_TYPE.'/EntityFactoryTest';
14
15
    private const TEST_ENTITY_FQN = self::TEST_PROJECT_ROOT_NAMESPACE.'\\Entities\\TestEntity';
16
17
    private $entityFqn;
18
19
    /**
20
     * @var EntityFactory
21
     */
22
    private $factory;
23
24
    private $built = false;
25
26
    public function setup()
27
    {
28
        parent::setup();
29
        if (false === $this->built) {
30
            $this->getEntityGenerator()->generateEntity(self::TEST_ENTITY_FQN);
31
            $this->getFieldSetter()->setEntityHasField(
32
                self::TEST_ENTITY_FQN,
33
                IsbnFieldTrait::class
34
            );
35
            $this->getFieldSetter()->setEntityHasField(
36
                self::TEST_ENTITY_FQN,
37
                EmailAddressFieldTrait::class
38
            );
39
            $this->built = true;
40
        }
41
        $this->setupCopiedWorkDir();
42
        $this->entityFqn = $this->getCopiedFqn(self::TEST_ENTITY_FQN);
43
        $this->factory   = $this->container->get(EntityFactory::class);
44
    }
45
46
    /**
47
     * @test
48
     *
49
     */
50
    public function itCanCreateAnEmptyEntity()
51
    {
52
        $entity = $this->factory->create($this->entityFqn);
53
        $this->assertInstanceOf($this->entityFqn, $entity);
54
    }
55
56
    /**
57
     * @test
58
     *
59
     */
60
    public function itThrowsAnExceptionIfThereIsAnInvalidProperty()
61
    {
62
        $this->expectException(\InvalidArgumentException::class);
63
        $this->factory->create($this->entityFqn, ['invalidProperty' => true]);
64
    }
65
66
    /**
67
     * @test
68
     *
69
     */
70
    public function itCanCreateAnEntityWithValues()
71
    {
72
        $values = [
73
            IsbnFieldInterface::PROP_ISBN                  => '978-3-16-148410-0',
74
            EmailAddressFieldInterface::PROP_EMAIL_ADDRESS => '[email protected]',
75
        ];
76
        $entity = $this->factory->create($this->entityFqn, $values);
77
78
        $this->assertSame($entity->getIsbn(), $values[IsbnFieldInterface::PROP_ISBN]);
79
80
        $this->assertSame($entity->getEmailAddress(), $values[EmailAddressFieldInterface::PROP_EMAIL_ADDRESS]);
81
    }
82
}
83