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

JtwTest   A

Complexity

Total Complexity 2

Size/Duplication

Total Lines 26
Duplicated Lines 0 %

Importance

Changes 2
Bugs 1 Features 2
Metric Value
wmc 2
eloc 6
c 2
b 1
f 2
dl 0
loc 26
rs 10

2 Methods

Rating   Name   Duplication   Size   Complexity  
A testGenerateToken() 0 7 1
A testJwtException() 0 5 1
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