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 ( 220e03...c6ffc1 )
by Christian
01:21
created

SessionTimeProviderTest::testIsValidWithMaxTime()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 10

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
dl 0
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\AntiSpamBundle\Tests\Provider;
11
12
use Core23\AntiSpamBundle\Provider\SessionTimeProvider;
13
use Core23\AntiSpamBundle\Provider\TimeProviderInterface;
14
use DateTime;
15
use PHPUnit\Framework\TestCase;
16
use Prophecy\Argument;
17
use Symfony\Component\HttpFoundation\Session\Session;
18
19
class SessionTimeProviderTest extends TestCase
20
{
21
    public function testItIsInstantiable(): void
22
    {
23
        $session = $this->prophesize(Session::class);
24
25
        $provider = new SessionTimeProvider($session->reveal());
26
27
        $this->assertInstanceOf(TimeProviderInterface::class, $provider);
28
    }
29
30
    public function testCreateFromString(): void
31
    {
32
        $session = $this->prophesize(Session::class);
33
        $session->set('antispam_foobar', Argument::type(DateTime::class))
34
            ->shouldBeCalled()
35
        ;
36
37
        $provider = new SessionTimeProvider($session->reveal());
38
        $provider->createFormProtection('foobar');
39
    }
40
41
    public function testIsValid(): void
42
    {
43
        $session  = $this->prepareValidSessionKey();
44
45
        $provider = new SessionTimeProvider($session->reveal());
46
47
        $this->assertTrue($provider->isValid('foobar', []));
48
    }
49
50
    public function testIsValidWithMinTime(): void
51
    {
52
        $session  = $this->prepareValidSessionKey();
53
54
        $provider = new SessionTimeProvider($session->reveal());
55
56
        $this->assertTrue($provider->isValid('foobar', [
57
            'min' => 10,
58
        ]));
59
    }
60
61
    public function testIsValidWithMaxTime(): void
62
    {
63
        $session  = $this->prepareValidSessionKey();
64
65
        $provider = new SessionTimeProvider($session->reveal());
66
67
        $this->assertTrue($provider->isValid('foobar', [
68
            'max' => 60,
69
        ]));
70
    }
71
72
    public function testIsInvalid(): void
73
    {
74
        $session = $this->prophesize(Session::class);
75
        $session->has('antispam_foobar')
76
            ->willReturn(false)
77
        ;
78
79
        $provider = new SessionTimeProvider($session->reveal());
80
81
        $this->assertFalse($provider->isValid('foobar', []));
82
    }
83
84
    public function testIsInvalidBecauseOfMinTime(): void
85
    {
86
        $session  = $this->prepareValidSessionKey();
87
88
        $provider = new SessionTimeProvider($session->reveal());
89
        $this->assertFalse($provider->isValid('foobar', [
90
            'min' => 60,
91
        ]));
92
    }
93
94
    public function testIsInvalidBecauseOfMaxTime(): void
95
    {
96
        $session  = $this->prepareValidSessionKey();
97
        $provider = new SessionTimeProvider($session->reveal());
98
99
        $this->assertFalse($provider->isValid('foobar', [
100
            'max' => 10,
101
        ]));
102
    }
103
104
    public function testRemoveFormProtection(): void
105
    {
106
        $session = $this->prophesize(Session::class);
107
        $session->remove('antispam_foobar')
108
            ->shouldBeCalled()
109
        ;
110
111
        $provider = new SessionTimeProvider($session->reveal());
112
        $provider->removeFormProtection('foobar');
113
    }
114
115
    private function prepareValidSessionKey()
116
    {
117
        $session = $this->prophesize(Session::class);
118
        $session->has('antispam_foobar')
119
            ->willReturn(true)
120
        ;
121
        $session->get('antispam_foobar')
122
            ->willReturn(new DateTime('- 15 seconds'))
123
        ;
124
125
        return $session;
126
    }
127
}
128