Completed
Push — master ( 2ad467...7fcbe3 )
by Guillaume
05:11
created

JwtManagerTest   A

Complexity

Total Complexity 1

Size/Duplication

Total Lines 30
Duplicated Lines 0 %

Coupling/Cohesion

Components 0
Dependencies 8

Importance

Changes 1
Bugs 0 Features 0
Metric Value
wmc 1
c 1
b 0
f 0
lcom 0
cbo 8
dl 0
loc 30
rs 10

1 Method

Rating   Name   Duplication   Size   Complexity  
B testGetToken() 0 24 1
1
<?php
2
3
namespace Eljam\GuzzleJwt\Tests\Manager;
4
5
use Eljam\GuzzleJwt\JwtToken;
6
use Eljam\GuzzleJwt\Manager\JwtManager;
7
use Eljam\GuzzleJwt\Strategy\Auth\QueryAuthStrategy;
8
use GuzzleHttp\Client;
9
use GuzzleHttp\HandlerStack;
10
use GuzzleHttp\Handler\MockHandler;
11
use GuzzleHttp\Psr7\Response;
12
13
/**
14
 * @author Guillaume Cavavana <[email protected]>
15
 */
16
class JwtManagerTest extends \PHPUnit_Framework_TestCase
17
{
18
    /**
19
     * testGetToken.
20
     */
21
    public function testGetToken()
22
    {
23
        $mock = new MockHandler([
24
            new Response(
25
                200,
26
                ['Content-Type' => 'application/json'],
27
                json_encode(['token' => '1453720507'])
28
            ), ]
29
        );
30
31
        $handler = HandlerStack::create($mock);
32
33
        $authClient = new Client([
34
            'handler' => $handler,
35
        ]);
36
37
        $authStrategy = new QueryAuthStrategy(['username' => 'admin', 'password' => 'admin']);
38
39
        $jwtManager = new JwtManager($authClient, $authStrategy);
40
        $token = $jwtManager->getJwtToken();
41
42
        $this->assertInstanceOf(JwtToken::class, $token);
43
        $this->assertEquals('1453720507', $token->getToken());
44
    }
45
}
46