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.

testAcceptBothSelfAndStaticDocblockTypeQualifiers()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 12
Code Lines 5

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
cc 1
eloc 5
c 1
b 0
f 0
nc 1
nop 0
dl 0
loc 12
rs 10
1
<?php
2
declare(strict_types=1);
3
namespace Thunder\Platenum\Tests;
4
5
use Thunder\Platenum\Enum\DocblockEnumTrait;
6
use Thunder\Platenum\Exception\PlatenumException;
7
use Thunder\Platenum\Tests\Fake\FakeEnum;
8
9
/**
10
 * @author Tomasz Kowalczyk <[email protected]>
11
 */
12
final class DocblockEnumTest extends AbstractTestCase
13
{
14
    public function testMembers(): void
15
    {
16
        $members = ['FIRST' => 1, 'SECOND' => 2];
17
        $trait = $this->makeDocblockTraitEnum($members);
18
        $extends = $this->makeDocblockExtendsEnum($members);
19
20
        $expected = ['FIRST' => 'FIRST', 'SECOND' => 'SECOND'];
21
        $this->assertSame($expected, $trait::getMembersAndValues());
22
        $this->assertSame($expected, $extends::getMembersAndValues());
23
    }
24
25
    public function testAcceptBothSelfAndStaticDocblockTypeQualifiers(): void
26
    {
27
        /** @var FakeEnum $enum */
28
        $enum = $this->computeUniqueClassName('X');
29
        eval('/**
0 ignored issues
show
introduced by
The use of eval() is discouraged.
Loading history...
30
         * @method static self FIRST()
31
         * @method static static SECOND()
32
         */
33
        class '.$enum.' { use '.DocblockEnumTrait::class.'; }');
34
35
        $this->assertSame('FIRST', $enum::FIRST()->getValue());
36
        $this->assertSame('SECOND', $enum::SECOND()->getValue());
37
    }
38
39
    public function testExceptionDocblockNotPresent(): void
40
    {
41
        /** @var FakeEnum $enum */
42
        $enum = $this->computeUniqueClassName('X');
43
        eval('class '.$enum.' { use '.DocblockEnumTrait::class.'; }');
0 ignored issues
show
introduced by
The use of eval() is discouraged.
Loading history...
44
45
        $this->expectException(PlatenumException::class);
46
        $this->expectExceptionMessage('Enum '.$enum.' does not have a docblock with member definitions.');
47
        $enum::FIRST();
48
    }
49
50
    public function testExceptionDocblockWithoutMembers(): void
51
    {
52
        /** @var FakeEnum $enum */
53
        $enum = $this->computeUniqueClassName('X');
54
        eval('/**
0 ignored issues
show
introduced by
The use of eval() is discouraged.
Loading history...
55
         * @author Tomasz Kowalczyk <[email protected]>
56
         */
57
        class '.$enum.' { use '.DocblockEnumTrait::class.'; }');
58
59
        $this->expectException(PlatenumException::class);
60
        $this->expectExceptionMessage('Enum '.$enum.' contains docblock without any member definitions.');
61
        $enum::FIRST();
62
    }
63
64
    public function testExceptionMalformedDocblockMembers(): void
65
    {
66
        /** @var FakeEnum $enum */
67
        $enum = $this->computeUniqueClassName('X');
68
        eval('/**
0 ignored issues
show
introduced by
The use of eval() is discouraged.
Loading history...
69
         * @author Tomasz Kowalczyk <[email protected]>
70
         *
71
         * @method static self FIRST()
72
         * @method static self INV*ALID()
73
         */
74
        class '.$enum.' { use '.DocblockEnumTrait::class.'; }');
75
76
        $this->expectException(PlatenumException::class);
77
        $this->expectExceptionMessage('Enum '.$enum.' contains malformed docblock member definitions.');
78
        $enum::FIRST();
79
    }
80
}
81