Passed
Pull Request — master (#1312)
by Michael
07:24
created

TokenReaderTest::tearDown()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 3
Code Lines 1

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
cc 1
eloc 1
c 1
b 0
f 0
nc 1
nop 0
dl 0
loc 3
rs 10
1
<?php
2
3
declare(strict_types=1);
4
5
namespace Xmf\Test\Jwt;
6
7
use PHPUnit\Framework\TestCase;
0 ignored issues
show
Bug introduced by
The type PHPUnit\Framework\TestCase was not found. Maybe you did not declare it correctly or list all dependencies?

The issue could also be caused by a filter entry in the build configuration. If the path has been excluded in your configuration, e.g. excluded_paths: ["lib/*"], you can move it to the dependency path list as follows:

filter:
    dependency_paths: ["lib/*"]

For further information see https://scrutinizer-ci.com/docs/tools/php/php-scrutinizer/#list-dependency-paths

Loading history...
8
9
use Xmf\Jwt\KeyFactory;
10
use Xmf\Jwt\JsonWebToken;
11
use Xmf\Jwt\TokenReader;
12
use Xmf\Key\ArrayStorage;
13
use Xmf\Key\KeyAbstract;
14
15
class TokenReaderTest extends TestCase
16
{
17
    /**
18
     * @var ArrayStorage
19
     */
20
    protected $storage;
21
    /**
22
     * @var KeyAbstract
23
     */
24
    protected $testKey;
25
    /**
26
     * @var string
27
     */
28
    protected $testKeyName = 'x-unit-test-key';
29
30
    /**
31
     * Sets up the fixture, for example, opens a network connection.
32
     * This method is called before a test is executed.
33
     */
34
    protected function setUp(): void
35
    {
36
        $this->storage = new ArrayStorage();
37
        $this->testKey = KeyFactory::build($this->testKeyName, $this->storage);
38
    }
39
40
    /**
41
     * Tears down the fixture, for example, closes a network connection.
42
     * This method is called after a test is executed.
43
     */
44
    protected function tearDown(): void
45
    {
46
        $this->storage->delete($this->testKeyName);
47
    }
48
49
    public function testFromString()
50
    {
51
        $claims = ['rat' => 'cute'];
52
        $jwt    = new JsonWebToken($this->testKey);
53
        $token  = $jwt->create($claims);
54
55
        $actual = TokenReader::fromString($this->testKey, $token);
56
        foreach ($claims as $name => $value) {
57
            $this->assertEquals($value, $actual->$name);
58
        }
59
60
        $actual = TokenReader::fromString($this->testKey, $token, ['rat' => 'odd']);
61
        $this->assertFalse($actual);
62
    }
63
64
    public function testFromCookie()
65
    {
66
        // Remove the following lines when you implement this test.
67
        $this->markTestIncomplete(
68
            'This test has not been implemented yet.'
69
        );
70
    }
71
72
    public function testFromRequest()
73
    {
74
        // Remove the following lines when you implement this test.
75
        $this->markTestIncomplete(
76
            'This test has not been implemented yet.'
77
        );
78
    }
79
80
    public function testFromHeader()
81
    {
82
        // Remove the following lines when you implement this test.
83
        $this->markTestIncomplete(
84
            'This test has not been implemented yet.'
85
        );
86
    }
87
}
88