Completed
Push — master ( ff92f6...3ef1d3 )
by John
09:08
created

DecoderTest::willDecodeTestCasesFromJwtDotIo()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 5
Code Lines 3

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
dl 0
loc 5
rs 9.4285
c 0
b 0
f 0
cc 1
eloc 3
nc 1
nop 2
1
<?php
2
/*
3
 * This file is part of the KleijnWeb\JwtBundle package.
4
 *
5
 * For the full copyright and license information, please view the LICENSE
6
 * file that was distributed with this source code.
7
 */
8
namespace KleijnWeb\JwtBundle\Tests\Jwt;
9
10
use KleijnWeb\JwtBundle\Jwt\Decoder;
11
12
/**
13
 * @author John Kleijn <[email protected]>
14
 */
15
class DecoderTest extends \PHPUnit_Framework_TestCase
16
{
17
    /**
18
     * @test
19
     * @expectedException \RuntimeException
20
     */
21
    public function willThrowExceptionWhenJsonDecodeFails()
22
    {
23
        $decoder = new Decoder();
24
        $decoder->jsonDecode('lkjhhkjjhkl');
25
    }
26
27
    /**
28
     * @param string $data
29
     * @param array  $source
30
     *
31
     * @test
32
     * @dataProvider testSetProvider
33
     */
34
    public function willDecodeTestCasesFromJwtDotIo($source, $data)
35
    {
36
        $decoder = new Decoder();
37
        $this->assertSame($source, $decoder->decode($data));
38
    }
39
40
    /**
41
     * @see          http://jwt.io/
42
     * @return array
43
     */
44 View Code Duplication
    public static function testSetProvider()
0 ignored issues
show
Duplication introduced by
This method seems to be duplicated in your project.

Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation.

You can also find more detailed suggestions in the “Code” section of your repository.

Loading history...
45
    {
46
        return [
47
            [
48
                [
49
                    'alg' => 'HS256',
50
                    'typ' => 'JWT',
51
                ],
52
                'eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9'
53
            ],
54
            [
55
                [
56
                    'sub'   => '1234567890',
57
                    'name'  => 'John Doe',
58
                    'admin' => true,
59
                ]
60
                ,
61
                'eyJzdWIiOiIxMjM0NTY3ODkwIiwibmFtZSI6IkpvaG4gRG9lIiwiYWRtaW4iOnRydWV9'
62
            ]
63
        ];
64
    }
65
}
66