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.

SessionManagerTest::testGetUsername()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 10

Duplication

Lines 10
Ratio 100 %

Importance

Changes 0
Metric Value
dl 10
loc 10
rs 9.9332
c 0
b 0
f 0
cc 1
nc 1
nop 0
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\Session;
11
12
use Core23\LastFm\Session\Session as LastFmSession;
13
use Core23\LastFmBundle\Session\SessionManager;
14
use PHPUnit\Framework\TestCase;
15
use Symfony\Component\HttpFoundation\Session\Session;
16
17
final class SessionManagerTest extends TestCase
18
{
19
    public function testIsAuthenticated(): void
20
    {
21
        $session = $this->prophesize(Session::class);
22
        $session->get('_CORE23_LASTFM_TOKEN')
23
            ->willReturn(true)
24
        ;
25
26
        $manager = new SessionManager($session->reveal());
27
        static::assertTrue($manager->isAuthenticated());
28
    }
29
30
    public function testIsNotAuthenticated(): void
31
    {
32
        $session = $this->prophesize(Session::class);
33
        $session->get('_CORE23_LASTFM_TOKEN')
34
            ->willReturn(false)
35
        ;
36
37
        $manager = new SessionManager($session->reveal());
38
        static::assertFalse($manager->isAuthenticated());
39
    }
40
41 View Code Duplication
    public function testGetUsername(): void
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...
42
    {
43
        $session = $this->prophesize(Session::class);
44
        $session->get('_CORE23_LASTFM_NAME')
45
            ->willReturn('MyUser')
46
        ;
47
48
        $manager = new SessionManager($session->reveal());
49
        static::assertSame('MyUser', $manager->getUsername());
50
    }
51
52
    public function testGetUsernameNotExist(): void
53
    {
54
        $session = $this->prophesize(Session::class);
55
        $session->get('_CORE23_LASTFM_NAME')
56
            ->willReturn(null)
57
        ;
58
59
        $manager = new SessionManager($session->reveal());
60
        static::assertNull($manager->getUsername());
61
    }
62
63
    public function testStore(): void
64
    {
65
        $lastfmSession = new LastFmSession('YourName', 'YourToken');
66
67
        $session = $this->prophesize(Session::class);
68
        $session->set('_CORE23_LASTFM_NAME', 'YourName')->shouldBeCalled();
69
        $session->set('_CORE23_LASTFM_TOKEN', 'YourToken')->shouldBeCalled();
70
71
        $manager = new SessionManager($session->reveal());
72
        $manager->store($lastfmSession);
73
    }
74
75 View Code Duplication
    public function testClear(): void
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...
76
    {
77
        $session = $this->prophesize(Session::class);
78
        $session->remove('_CORE23_LASTFM_TOKEN')->shouldBeCalled();
79
        $session->remove('_CORE23_LASTFM_NAME')->shouldBeCalled();
80
81
        $manager = new SessionManager($session->reveal());
82
        $manager->clear();
83
    }
84
85
    public function testGetSession(): void
86
    {
87
        $session = $this->prophesize(Session::class);
88
        $session->get('_CORE23_LASTFM_NAME')
89
            ->willReturn('MyUser')
90
        ;
91
        $session->get('_CORE23_LASTFM_TOKEN')
92
            ->willReturn('TheToken')
93
        ;
94
95
        $manager = new SessionManager($session->reveal());
96
97
        $lastfmSession = $manager->getSession();
98
99
        static::assertNotNull($lastfmSession);
100
        static::assertSame('MyUser', $lastfmSession->getName());
101
        static::assertSame('TheToken', $lastfmSession->getKey());
102
    }
103
104
    public function testGetSessionWithNoAuth(): void
105
    {
106
        $session = $this->prophesize(Session::class);
107
        $session->get('_CORE23_LASTFM_TOKEN')
108
            ->willReturn(null)
109
        ;
110
111
        $manager = new SessionManager($session->reveal());
112
113
        static::assertNull($manager->getSession());
114
    }
115
}
116