AbstractEnumTests   A
last analyzed

Complexity

Total Complexity 3

Size/Duplication

Total Lines 47
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 2

Importance

Changes 0
Metric Value
wmc 3
lcom 1
cbo 2
dl 0
loc 47
rs 10
c 0
b 0
f 0

3 Methods

Rating   Name   Duplication   Size   Complexity  
A basicUse() 0 4 1
A badConstant() 0 4 1
A all() 0 7 1
1
<?php
2
namespace SubjectivePHPTest\Spl\Types;
3
4
use SubjectivePHP\Spl\Types\AbstractEnum;
5
use PHPUnit\Framework\TestCase;
6
7
/**
8
 * Unit tests for the SubjectivePHP\Spl\Types\AbstractEnum class.
9
 *
10
 * @coversDefaultClass \SubjectivePHP\Spl\Types\AbstractEnum
11
 * @covers ::<private>
12
 */
13
final class AbstractEnumTests extends TestCase
14
{
15
    /**
16
     * Verify basic behavior of __callStatic.
17
     *
18
     * @test
19
     * @covers ::__callStatic
20
     * @covers ::__toString
21
     *
22
     * @return void
23
     */
24
    public function basicUse()
25
    {
26
        $this->assertSame(SimpleEnum::FOO, (string)SimpleEnum::Foo());
27
    }
28
29
    /**
30
     * Verify exception is thrown if __callStatic is invoked with an invalid value.
31
     *
32
     * @test
33
     * @covers ::__callStatic
34
     * @expectedException \UnexpectedValueException
35
     * @expectedExceptionMessage 'Invalid' is not a valid SubjectivePHPTest\Spl\Types\SimpleEnum
36
     *
37
     * @return void
38
     */
39
    public function badConstant()
40
    {
41
        /** @scrutinizer ignore-call */ SimpleEnum::Invalid();
42
    }
43
44
    /**
45
     * Verify basic behavior of all().
46
     *
47
     * @test
48
     * @covers ::all
49
     *
50
     * @return void
51
     */
52
    public function all()
53
    {
54
        $all = SimpleEnum::all();
55
        $this->assertCount(2, $all);
56
        $this->assertSame(SimpleEnum::FOO, (string)$all[0]);
57
        $this->assertSame(SimpleEnum::BAR, (string)$all[1]);
58
    }
59
}
60