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 ( 70c46b...316b2b )
by Hilari
02:09
created

RedisCacheSpec   A

Complexity

Total Complexity 7

Size/Duplication

Total Lines 50
Duplicated Lines 0 %

Coupling/Cohesion

Components 0
Dependencies 2

Importance

Changes 1
Bugs 0 Features 0
Metric Value
wmc 7
c 1
b 0
f 0
lcom 0
cbo 2
dl 0
loc 50
rs 10

7 Methods

Rating   Name   Duplication   Size   Complexity  
A let() 0 4 1
A it_is_initializable() 0 5 1
A it_can_store_items() 0 6 1
A it_can_store_items_for_a_limited_period_of_time() 0 6 1
A it_can_check_the_existence_of_an_item_in_the_cache() 0 6 1
A it_throws_an_exception_when_trying_to_get_a_non_set_item() 0 7 1
A it_can_return_a_default_value_when_pulling_a_non_set_item() 0 7 1
1
<?php
2
3
namespace spec\Cmp\Cache\Infrastructure;
4
5
use Cmp\Cache\Domain\Exceptions\NotFoundException;
6
use PhpSpec\ObjectBehavior;
7
use Redis;
8
9
/**
10
 * Class RedisCacheSpec
11
 *
12
 * @package spec\Cmp\Cache\Infrastructure
13
 * @mixin \Cmp\Cache\Infrastructure\RedisCache
14
 */
15
class RedisCacheSpec extends ObjectBehavior
16
{
17
    function let(Redis $redis)
18
    {
19
        $this->beConstructedWith($redis);
20
    }
21
22
    function it_is_initializable()
23
    {
24
        $this->shouldHaveType('Cmp\Cache\Infrastructure\RedisCache');
25
        $this->shouldHaveType('Cmp\Cache\Domain\Cache');
26
    }
27
28
    function it_can_store_items(Redis $redis)
29
    {
30
        $this->set('foo', 'bar');
31
32
        $redis->set('foo', 'bar')->shouldHaveBeenCalled();
33
    }
34
35
    function it_can_store_items_for_a_limited_period_of_time(Redis $redis)
36
    {
37
        $this->set('foo', 'bar', 1);
38
39
        $redis->setex('foo', 1, 'bar')->shouldHaveBeenCalled();
40
    }
41
42
    function it_can_check_the_existence_of_an_item_in_the_cache(Redis $redis)
43
    {
44
        $redis->exists('foo')->willReturn(true);
45
46
        $this->has('foo')->shouldReturn(true);
47
    }
48
49
    function it_throws_an_exception_when_trying_to_get_a_non_set_item(Redis $redis)
50
    {
51
        $redis->get('foo')->willReturn(null);
52
        $redis->exists('foo')->willReturn(false);
53
54
        $this->shouldThrow(new NotFoundException('foo'))->duringGet('foo');
55
    }
56
57
    function it_can_return_a_default_value_when_pulling_a_non_set_item(Redis $redis)
58
    {
59
        $redis->get('foo')->willReturn(null);
60
        $redis->exists('foo')->willReturn(false);
61
62
        $this->pull('foo', 'bar')->shouldReturn('bar');
63
    }
64
}
65