GitHub Access Token became invalid

It seems like the GitHub access token used for retrieving details about this repository from GitHub became invalid. This might prevent certain types of inspections from being run (in particular, everything related to pull requests).
Please ask an admin of your repository to re-new the access token on this website.

CheckAuthActionTest   A
last analyzed

Complexity

Total Complexity 4

Size/Duplication

Total Lines 86
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 3

Importance

Changes 0
Metric Value
wmc 4
lcom 1
cbo 3
dl 0
loc 86
rs 10
c 0
b 0
f 0

4 Methods

Rating   Name   Duplication   Size   Complexity  
A setUp() 0 6 1
A testExecute() 0 27 1
A testExecuteWithNoToken() 0 19 1
A testExecuteWithNoSession() 0 22 1
1
<?php
2
3
/*
4
 * (c) Christian Gripp <[email protected]>
5
 *
6
 * For the full copyright and license information, please view the LICENSE
7
 * file that was distributed with this source code.
8
 */
9
10
namespace Core23\LastFmBundle\Tests\Action;
11
12
use Core23\LastFm\Service\AuthServiceInterface;
13
use Core23\LastFm\Session\SessionInterface;
14
use Core23\LastFmBundle\Action\CheckAuthAction;
15
use Core23\LastFmBundle\Session\SessionManagerInterface;
16
use PHPUnit\Framework\TestCase;
17
use Prophecy\Argument;
18
use Symfony\Component\HttpFoundation\Request;
19
use Symfony\Component\Routing\Generator\UrlGeneratorInterface;
20
use Symfony\Component\Routing\RouterInterface;
21
22
final class CheckAuthActionTest extends TestCase
23
{
24
    private $router;
25
26
    private $sessionManager;
27
28
    private $authService;
29
30
    protected function setUp(): void
31
    {
32
        $this->router         = $this->prophesize(RouterInterface::class);
33
        $this->sessionManager = $this->prophesize(SessionManagerInterface::class);
34
        $this->authService    = $this->prophesize(AuthServiceInterface::class);
35
    }
36
37
    public function testExecute(): void
38
    {
39
        $this->sessionManager->store(Argument::type(SessionInterface::class))
40
            ->shouldBeCalled()
41
        ;
42
43
        $this->router->generate('core23_lastfm_success', [], UrlGeneratorInterface::ABSOLUTE_PATH)
44
            ->willReturn('/success')
45
        ;
46
47
        $this->authService->createSession('MY_TOKEN')
48
            ->willReturn($this->prophesize(SessionInterface::class))
49
        ;
50
51
        $request = new Request();
52
        $request->query->set('token', 'MY_TOKEN');
53
54
        $action = new CheckAuthAction(
55
            $this->router->reveal(),
56
            $this->sessionManager->reveal(),
57
            $this->authService->reveal()
58
        );
59
60
        $response = $action($request);
61
62
        static::assertSame('/success', $response->getTargetUrl());
63
    }
64
65
    public function testExecuteWithNoToken(): void
66
    {
67
        $this->router->generate('core23_lastfm_auth', [], UrlGeneratorInterface::ABSOLUTE_PATH)
68
            ->willReturn('/auth')
69
        ;
70
71
        $request = new Request();
72
        $request->query->set('token', null);
73
74
        $action = new CheckAuthAction(
75
            $this->router->reveal(),
76
            $this->sessionManager->reveal(),
77
            $this->authService->reveal()
78
        );
79
80
        $response = $action($request);
81
82
        static::assertSame('/auth', $response->getTargetUrl());
83
    }
84
85
    public function testExecuteWithNoSession(): void
86
    {
87
        $this->router->generate('core23_lastfm_error', [], UrlGeneratorInterface::ABSOLUTE_PATH)
88
            ->willReturn('/error')
89
        ;
90
        $this->authService->createSession('MY_TOKEN')
91
            ->willReturn(null)
92
        ;
93
94
        $request = new Request();
95
        $request->query->set('token', 'MY_TOKEN');
96
97
        $action = new CheckAuthAction(
98
            $this->router->reveal(),
99
            $this->sessionManager->reveal(),
100
            $this->authService->reveal()
101
        );
102
103
        $response = $action($request);
104
105
        static::assertSame('/error', $response->getTargetUrl());
106
    }
107
}
108