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.
Completed
Push — master ( fc38fb...ac880e )
by Christian
05:32
created

SessionManagerTest::testClear()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 12

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
dl 0
loc 12
rs 9.8666
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\FacebookBundle\Tests\Session;
11
12
use Core23\FacebookBundle\Session\Session as FacebookSession;
13
use Core23\FacebookBundle\Session\SessionInterface;
14
use Core23\FacebookBundle\Session\SessionManager;
15
use DateTime;
16
use PHPUnit\Framework\TestCase;
17
use Prophecy\Argument;
18
use Prophecy\Prophecy\ObjectProphecy;
19
use Symfony\Component\HttpFoundation\Session\Session;
20
21
class SessionManagerTest extends TestCase
22
{
23 View Code Duplication
    public function testIsAuthenticated(): 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...
24
    {
25
        /** @var ObjectProphecy&Session $session */
0 ignored issues
show
Documentation introduced by
The doc-type ObjectProphecy&Session could not be parsed: Unknown type name "ObjectProphecy&Session" at position 0. (view supported doc-types)

This check marks PHPDoc comments that could not be parsed by our parser. To see which comment annotations we can parse, please refer to our documentation on supported doc-types.

Loading history...
26
        $session = $this->prophesize(Session::class);
27
        $session->get('_CORE23_FACEBOOK_TOKEN')
28
            ->willReturn(true)
29
        ;
30
31
        $manager = new SessionManager($session->reveal());
32
        $this->assertTrue($manager->isAuthenticated());
33
    }
34
35 View Code Duplication
    public function testIsNotAuthenticated(): 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...
36
    {
37
        /** @var ObjectProphecy&Session $session */
0 ignored issues
show
Documentation introduced by
The doc-type ObjectProphecy&Session could not be parsed: Unknown type name "ObjectProphecy&Session" at position 0. (view supported doc-types)

This check marks PHPDoc comments that could not be parsed by our parser. To see which comment annotations we can parse, please refer to our documentation on supported doc-types.

Loading history...
38
        $session = $this->prophesize(Session::class);
39
        $session->get('_CORE23_FACEBOOK_TOKEN')
40
            ->willReturn(false)
41
        ;
42
43
        $manager = new SessionManager($session->reveal());
44
        $this->assertFalse($manager->isAuthenticated());
45
    }
46
47 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...
48
    {
49
        /** @var ObjectProphecy&Session $session */
0 ignored issues
show
Documentation introduced by
The doc-type ObjectProphecy&Session could not be parsed: Unknown type name "ObjectProphecy&Session" at position 0. (view supported doc-types)

This check marks PHPDoc comments that could not be parsed by our parser. To see which comment annotations we can parse, please refer to our documentation on supported doc-types.

Loading history...
50
        $session = $this->prophesize(Session::class);
51
        $session->get('_CORE23_FACEBOOK_NAME')
52
            ->willReturn('MyUser')
53
        ;
54
55
        $manager = new SessionManager($session->reveal());
56
        $this->assertSame('MyUser', $manager->getUsername());
57
    }
58
59 View Code Duplication
    public function testGetUsernameNotExist(): 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...
60
    {
61
        /** @var ObjectProphecy&Session $session */
0 ignored issues
show
Documentation introduced by
The doc-type ObjectProphecy&Session could not be parsed: Unknown type name "ObjectProphecy&Session" at position 0. (view supported doc-types)

This check marks PHPDoc comments that could not be parsed by our parser. To see which comment annotations we can parse, please refer to our documentation on supported doc-types.

Loading history...
62
        $session = $this->prophesize(Session::class);
63
        $session->get('_CORE23_FACEBOOK_NAME')
64
            ->willReturn(null)
65
        ;
66
67
        $manager = new SessionManager($session->reveal());
68
        $this->assertNull($manager->getUsername());
69
    }
70
71 View Code Duplication
    public function testStore(): 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...
72
    {
73
        $facebookSession = new FacebookSession('4711', 'YourName', 'YourToken', new DateTime());
74
75
        /** @var ObjectProphecy&Session $session */
0 ignored issues
show
Documentation introduced by
The doc-type ObjectProphecy&Session could not be parsed: Unknown type name "ObjectProphecy&Session" at position 0. (view supported doc-types)

This check marks PHPDoc comments that could not be parsed by our parser. To see which comment annotations we can parse, please refer to our documentation on supported doc-types.

Loading history...
76
        $session = $this->prophesize(Session::class);
77
        $session->set('_CORE23_FACEBOOK_ID', '4711')->shouldBeCalled();
78
        $session->set('_CORE23_FACEBOOK_NAME', 'YourName')->shouldBeCalled();
79
        $session->set('_CORE23_FACEBOOK_TOKEN', 'YourToken')->shouldBeCalled();
80
        $session->set('_CORE23_FACEBOOK_EXPIRES', Argument::type(DateTime::class))->shouldBeCalled();
81
82
        $manager = new SessionManager($session->reveal());
83
        $manager->store($facebookSession);
84
85
        $this->assertTrue(true);
86
    }
87
88 View Code Duplication
    public function testStoreWithNoExpiryDate(): 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...
89
    {
90
        $facebookSession = new FacebookSession('4711', 'YourName', 'YourToken', null);
91
92
        /** @var ObjectProphecy&Session $session */
0 ignored issues
show
Documentation introduced by
The doc-type ObjectProphecy&Session could not be parsed: Unknown type name "ObjectProphecy&Session" at position 0. (view supported doc-types)

This check marks PHPDoc comments that could not be parsed by our parser. To see which comment annotations we can parse, please refer to our documentation on supported doc-types.

Loading history...
93
        $session = $this->prophesize(Session::class);
94
        $session->set('_CORE23_FACEBOOK_ID', '4711')->shouldBeCalled();
95
        $session->set('_CORE23_FACEBOOK_NAME', 'YourName')->shouldBeCalled();
96
        $session->set('_CORE23_FACEBOOK_TOKEN', 'YourToken')->shouldBeCalled();
97
        $session->set('_CORE23_FACEBOOK_EXPIRES', Argument::is(null))->shouldBeCalled();
98
99
        $manager = new SessionManager($session->reveal());
100
        $manager->store($facebookSession);
101
102
        $this->assertTrue(true);
103
    }
104
105
    public function testClear(): void
106
    {
107
        /** @var ObjectProphecy&Session $session */
0 ignored issues
show
Documentation introduced by
The doc-type ObjectProphecy&Session could not be parsed: Unknown type name "ObjectProphecy&Session" at position 0. (view supported doc-types)

This check marks PHPDoc comments that could not be parsed by our parser. To see which comment annotations we can parse, please refer to our documentation on supported doc-types.

Loading history...
108
        $session = $this->prophesize(Session::class);
109
        $session->remove('_CORE23_FACEBOOK_ID')->shouldBeCalled();
110
        $session->remove('_CORE23_FACEBOOK_TOKEN')->shouldBeCalled();
111
        $session->remove('_CORE23_FACEBOOK_NAME')->shouldBeCalled();
112
        $session->remove('_CORE23_FACEBOOK_EXPIRES')->shouldBeCalled();
113
114
        $manager = new SessionManager($session->reveal());
115
        $manager->clear();
116
    }
117
118
    public function testGetSession(): void
119
    {
120
        $tomorrow = new DateTime('tomorrow');
121
122
        /** @var ObjectProphecy&Session $session */
0 ignored issues
show
Documentation introduced by
The doc-type ObjectProphecy&Session could not be parsed: Unknown type name "ObjectProphecy&Session" at position 0. (view supported doc-types)

This check marks PHPDoc comments that could not be parsed by our parser. To see which comment annotations we can parse, please refer to our documentation on supported doc-types.

Loading history...
123
        $session = $this->prophesize(Session::class);
124
        $session->get('_CORE23_FACEBOOK_ID')
125
            ->willReturn('0815')
126
        ;
127
        $session->get('_CORE23_FACEBOOK_TOKEN')
128
            ->willReturn('TheToken')
129
        ;
130
        $session->get('_CORE23_FACEBOOK_NAME')
131
            ->willReturn('MyUser')
132
        ;
133
        $session->get('_CORE23_FACEBOOK_EXPIRES')
134
            ->willReturn($tomorrow)
135
        ;
136
137
        $manager = new SessionManager($session->reveal());
138
139
        /** @var SessionInterface $facebookSession */
140
        $facebookSession = $manager->getSession();
141
142
        $this->assertNotNull($facebookSession);
143
        $this->assertSame('0815', $facebookSession->getFacebookId());
144
        $this->assertSame('MyUser', $facebookSession->getName());
145
        $this->assertSame('TheToken', $facebookSession->getToken());
146
        $this->assertSame($tomorrow, $facebookSession->getExpireDate());
147
    }
148
}
149