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
Push — master ( 8619f1...53d2ad )
by Ross
52s queued 13s
created

EntityValidatorTest::testInvalid()   A

Complexity

Conditions 3
Paths 3

Size

Total Lines 9
Code Lines 6

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
cc 3
eloc 6
nc 3
nop 0
dl 0
loc 9
rs 9.6666
c 0
b 0
f 0
1
<?php declare(strict_types=1);
2
3
namespace EdmondsCommerce\DoctrineStaticMeta\Entity\Validation;
4
5
use EdmondsCommerce\DoctrineStaticMeta\AbstractTest;
6
use EdmondsCommerce\DoctrineStaticMeta\CodeGeneration\Generator\AbstractGenerator;
7
use EdmondsCommerce\DoctrineStaticMeta\Entity\Fields\Interfaces\Attribute\IpAddressFieldInterface;
8
use EdmondsCommerce\DoctrineStaticMeta\Entity\Fields\Traits\Attribute\IpAddressFieldTrait;
9
use EdmondsCommerce\DoctrineStaticMeta\Exception\ValidationException;
10
11
class EntityValidatorTest extends AbstractTest
12
{
13
    public const WORK_DIR = AbstractTest::VAR_PATH.'/EntityValidatorTest';
14
15
    public const TEST_ENTITY_SERVER = self::TEST_PROJECT_ROOT_NAMESPACE.'\\'
16
                                      .AbstractGenerator::ENTITIES_FOLDER_NAME.'\\Server';
17
18
    public const TEST_ENTITY_SERVER_COPIED = self::TEST_ENTITY_SERVER.'Copied';
19
20
    public const VALID_IP_ADDRESSES = [
21
        '192.136.234.145',
22
    ];
23
24
    public const INVALID_IP_ADDRESSES = [
25
        'cheese',
26
        '192.136',
27
    ];
28
29
    /**
30
     * @var IpAddressFieldInterface
31
     */
32
    private $testEntity;
33
34
    public function setup()
35
    {
36
        parent::setup();
37
        $this->getEntityGenerator()->generateEntity(self::TEST_ENTITY_SERVER);
38
        $this->getFieldGenerator()->setEntityHasField(
39
            self::TEST_ENTITY_SERVER,
40
            IpAddressFieldTrait::class
41
        );
42
        file_put_contents(
43
            self::WORK_DIR.'/src/Entities/ServerCopied.php',
44
            str_replace(
45
                [
46
                    'class Server',
47
                ],
48
                [
49
                    'class ServerCopied',
50
                ],
51
                file_get_contents(self::WORK_DIR.'/src/Entities/Server.php')
52
            )
53
        );
54
        $entityValidator  = $this->container->get(EntityValidator::class);
55
        $class            = self::TEST_ENTITY_SERVER_COPIED;
56
        $this->testEntity = new $class($entityValidator);
57
    }
58
59
    public function testIsValid()
60
    {
61
        foreach (self::VALID_IP_ADDRESSES as $ipAddress) {
62
            $this->testEntity->setIpAddress($ipAddress);
63
            $this->assertEquals($ipAddress, $this->testEntity->getIpAddress());
64
        }
65
    }
66
67
    public function testInvalid()
68
    {
69
        foreach (self::INVALID_IP_ADDRESSES as $ipAddress) {
70
            $exception = null;
71
            try {
72
                $this->testEntity->setIpAddress($ipAddress);
73
            } catch (ValidationException $exception) {
0 ignored issues
show
Coding Style Comprehensibility introduced by
Consider adding a comment why this CATCH block is empty.
Loading history...
74
            }
75
            $this->assertInstanceOf(ValidationException::class, $exception);
76
        }
77
    }
78
}
79