TokenTypeTest::itCannotBeCreatedWithAUnknownType()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 4
Code Lines 2

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
dl 0
loc 4
rs 10
c 0
b 0
f 0
cc 1
eloc 2
nc 1
nop 0
1
<?php
2
3
namespace Bunq\Tests\Token;
4
5
use Bunq\Token\TokenType;
6
use PHPUnit\Framework\TestCase;
7
8
final class TokenTypeTest extends TestCase
9
{
10
    /**
11
     * @test
12
     */
13
    public function itRepresentsATokenType()
14
    {
15
        $token = TokenType::INSTALLATION_TOKEN();
16
17
        $this->assertInstanceOf(TokenType::class, $token);
18
        $this->assertEquals('installation.token', $token->toString());
19
        $this->assertEquals('installation.token', (string)$token);
20
21
        $this->assertTrue($token->equals(TokenType::INSTALLATION_TOKEN()));
22
        $this->assertFalse($token->equals(TokenType::SESSION_TOKEN()));
23
        $this->assertFalse($token->equals(new \stdClass()));
24
        $this->assertFalse($token->equals('class'));
25
    }
26
27
    /**
28
     * @test
29
     */
30
    public function itGiveAllTypesOfAToken()
31
    {
32
        $tokenTypes = TokenType::all();
33
34
        $expectedTokens = [
35
            TokenType::INSTALLATION_TOKEN(),
36
            TokenType::SESSION_TOKEN(),
37
        ];
38
39
        $this->assertEquals($expectedTokens, $tokenTypes);
40
    }
41
42
    /**
43
     * @test
44
     */
45
    public function itGiveAllTypesOfATokenAsString()
46
    {
47
        $tokenTypes = TokenType::allAsString();
48
49
        $expectedTokens = [
50
            TokenType::INSTALLATION_TOKEN,
51
            TokenType::SESSION_TOKEN,
52
        ];
53
54
        $this->assertEquals($expectedTokens, $tokenTypes);
55
    }
56
57
    /**
58
     * @test
59
     * @expectedException \InvalidArgumentException
60
     * @expectedExceptionMessage Invalid token type "unknownType"
61
     */
62
    public function itCannotBeCreatedWithAUnknownType()
63
    {
64
        TokenType::fromString('unknownType');
65
    }
66
}
67