Passed
Pull Request — master (#81)
by
unknown
05:47
created

RequestRefreshTokenSpec::let()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 7
Code Lines 4

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
c 0
b 0
f 0
dl 0
loc 7
rs 9.4285
cc 1
eloc 4
nc 1
nop 1
1
<?php
2
3
namespace spec\Gesdinet\JWTRefreshTokenBundle\Request;
4
5
use Gesdinet\JWTRefreshTokenBundle\NameGenerator\NameGeneratorInterface;
6
use PhpSpec\ObjectBehavior;
7
use Symfony\Component\HttpFoundation\Request;
8
9
class RequestRefreshTokenSpec extends ObjectBehavior
10
{
11
    function let(NameGeneratorInterface $nameGenerator)
12
    {
13
        $this->beConstructedWith($nameGenerator);
14
        
15
        $nameGenerator->generateName('refresh_token')
16
            ->willReturn('refresh_token');
17
    }
18
19
20
    public function it_gets_from_query_param()
21
    {
22
        $request = Request::createFromGlobals();
23
        $request->attributes->set('refresh_token', 'abcd');
24
25
        $this->getRefreshToken($request)->shouldBe('abcd');
26
    }
27
28
    public function it_gets_from_body()
29
    {
30
        $request = Request::createFromGlobals();
31
        $request->request->set('refresh_token', 'abcd');
32
33
        $this->getRefreshToken($request)->shouldBe('abcd');
34
    }
35
36 View Code Duplication
    public function it_gets_from_json()
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...
37
    {
38
        $request = Request::create(null, 'POST', array(), array(), array(), array(), json_encode(array('refresh_token' => 'abcd')));
39
        $request->headers->set('content_type', 'application/json');
40
41
        $this->getRefreshToken($request)->shouldBe('abcd');
42
    }
43
44 View Code Duplication
    public function it_gets_from_json_x()
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
        $request = Request::create(null, 'POST', array(), array(), array(), array(), json_encode(array('refresh_token' => 'abcd')));
47
        $request->headers->set('content_type', 'application/x-json');
48
49
        $this->getRefreshToken($request)->shouldBe('abcd');
50
    }
51
52 View Code Duplication
    public function it_gets_from_json_parameter()
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...
53
    {
54
        $request = Request::create(null, 'POST', array(), array(), array(), array(), json_encode(array('refresh_token' => 'abcd')));
55
        $request->headers->set('content_type', 'application/json;charset=UTF-8');
56
57
        $this->getRefreshToken($request)->shouldBe('abcd');
58
    }
59
60
61 View Code Duplication
    public function it_gets_from_query_param_using_camel_case_naming(NameGeneratorInterface $nameGenerator)
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...
62
    {
63
        $nameGenerator->generateName('refresh_token')
64
            ->willReturn('refreshToken');
65
66
        $request = Request::createFromGlobals();
67
        $request->attributes->set('refreshToken', 'abcd');
68
69
        $this->getRefreshToken($request)->shouldBe('abcd');
70
    }
71
72 View Code Duplication
    public function it_gets_from_body_using_camel_case_naming(NameGeneratorInterface $nameGenerator)
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...
73
    {
74
        $nameGenerator->generateName('refresh_token')
75
            ->willReturn('refreshToken');
76
77
        $request = Request::createFromGlobals();
78
        $request->request->set('refreshToken', 'abcd');
79
80
        $this->getRefreshToken($request)->shouldBe('abcd');
81
    }
82
83 View Code Duplication
    public function it_gets_from_json_using_camel_case_naming(NameGeneratorInterface $nameGenerator)
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...
84
    {
85
        $nameGenerator->generateName('refresh_token')
86
            ->willReturn('refreshToken');
87
88
        $request = Request::create(null, 'POST', array(), array(), array(), array(), json_encode(array('refreshToken' => 'abcd')));
89
        $request->headers->set('content_type', 'application/json');
90
91
        $this->getRefreshToken($request)->shouldBe('abcd');
92
    }
93
94 View Code Duplication
    public function it_gets_from_json_x_using_camel_case_naming(NameGeneratorInterface $nameGenerator)
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...
95
    {
96
        $nameGenerator->generateName('refresh_token')
97
            ->willReturn('refreshToken');
98
99
        $request = Request::create(null, 'POST', array(), array(), array(), array(), json_encode(array('refreshToken' => 'abcd')));
100
        $request->headers->set('content_type', 'application/x-json');
101
102
        $this->getRefreshToken($request)->shouldBe('abcd');
103
    }
104
105 View Code Duplication
    public function it_gets_from_json_parameter_using_camel_case_naming(NameGeneratorInterface $nameGenerator)
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...
106
    {
107
        $nameGenerator->generateName('refresh_token')
108
            ->willReturn('refreshToken');
109
110
        $request = Request::create(null, 'POST', array(), array(), array(), array(), json_encode(array('refreshToken' => 'abcd')));
111
        $request->headers->set('content_type', 'application/json;charset=UTF-8');
112
113
        $this->getRefreshToken($request)->shouldBe('abcd');
114
    }
115
}
116