Passed
Branch master (24feaf)
by Ion
02:29
created

JtwTest::testJwtException()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 5
Code Lines 2

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 1
Metric Value
eloc 2
c 1
b 0
f 1
dl 0
loc 5
rs 10
cc 1
nc 1
nop 0
1
<?php
2
declare(strict_types=1);
3
4
namespace IonGhitun\JwtToken\Tests;
5
6
use IonGhitun\JwtToken\Exceptions\JwtException;
7
use IonGhitun\JwtToken\Jwt;
8
use PHPUnit\Framework\TestCase;
9
10
/**
11
 * Class JtwTest
12
 *
13
 * @package IonGhitun\JwtToken\Tests
14
 */
15
class JtwTest extends TestCase
16
{
17
    /**
18
     * Test generate and validate token
19
     *
20
     * @throws JwtException
21
     */
22
    public function testGenerateToken()
23
    {
24
        $payload = ['test' => 'phpunit'];
25
26
        $token = Jwt::generateToken($payload);
27
28
        $this->assertArrayHasKey('test', Jwt::validateToken($token));
29
    }
30
31
    /**
32
     * Test not valid token
33
     *
34
     * @throws JwtException
35
     */
36
    public function testJwtException()
37
    {
38
        $this->expectException(JwtException::class);
39
40
        $payload = Jwt::validateToken('token');
0 ignored issues
show
Unused Code introduced by
The assignment to $payload is dead and can be removed.
Loading history...
41
    }
42
}
43