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

willThrowExceptionWhenJsonDecodeFails()   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 0
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\Encoder;
11
12
/**
13
 * @author John Kleijn <[email protected]>
14
 */
15
class EncoderTest extends \PHPUnit_Framework_TestCase
16
{
17
    /**
18
     * @param string $data
19
     * @param array  $source
20
     *
21
     * @test
22
     * @dataProvider testSetProvider
23
     */
24
    public function willDecodeTestCasesFromJwtDotIo($source, $data)
25
    {
26
        $encoder = new Encoder();
27
        $this->assertSame($data, $encoder->encode($source));
28
    }
29
30
    /**
31
     * @test
32
     * @expectedException \RuntimeException
33
     */
34
    public function willThrowExceptionWhenJsonDecodeFails()
35
    {
36
        $decoder = new Encoder();
37
        $decoder->jsonEncode("\xB1\x31");
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