Completed
Branch master (910c19)
by Dmitri
01:43
created

KeyTest   A

Complexity

Total Complexity 3

Size/Duplication

Total Lines 32
Duplicated Lines 0 %

Importance

Changes 0
Metric Value
eloc 10
dl 0
loc 32
rs 10
c 0
b 0
f 0
wmc 3
1
<?php
2
3
declare(strict_types=1);
4
5
namespace Damax\Bundle\ApiAuthBundle\Tests\Key;
6
7
use Damax\Bundle\ApiAuthBundle\Key\Key;
8
use PHPUnit\Framework\TestCase;
9
10
class KeyTest extends TestCase
11
{
12
    /**
13
     * @test
14
     */
15
    public function it_creates_valid_key()
16
    {
17
        $key = new Key('XYZ', 'john.doe', 3600);
18
19
        $this->assertEquals('XYZ', $key->key());
20
        $this->assertEquals('john.doe', $key->identity());
21
        $this->assertEquals(3600, $key->ttl());
22
        $this->assertFalse($key->expired());
23
    }
24
25
    /**
26
     * @test
27
     */
28
    public function it_creates_expired_key()
29
    {
30
        $key = new Key('XYZ', 'john.doe', -30);
31
32
        $this->assertEquals(0, $key->ttl());
33
        $this->assertTrue($key->expired());
34
    }
35
36
    /**
37
     * @test
38
     */
39
    public function it_implements_to_string()
40
    {
41
        $this->assertEquals('XYZ', (string) new Key('XYZ', 'john.doe', 3600));
42
    }
43
}
44