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
Pull Request — master (#2)
by Hilari
02:47
created

LoggerCacheSpec   A

Complexity

Total Complexity 15

Size/Duplication

Total Lines 122
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 5

Importance

Changes 2
Bugs 1 Features 0
Metric Value
wmc 15
c 2
b 1
f 0
lcom 1
cbo 5
dl 0
loc 122
rs 10
1
<?php
2
3
namespace spec\Cmp\Cache\Decorator;
4
5
use Cmp\Cache\Cache;
6
use Cmp\Cache\Decorator\CacheDecorator;
7
use Cmp\Cache\Exceptions\NotFoundException;
8
use PhpSpec\ObjectBehavior;
9
use Prophecy\Argument;
10
use Psr\Log\LoggerInterface;
11
use Psr\Log\LogLevel;
12
13
/**
14
 * Class LoggerCacheDecoratorSpec
15
 *
16
 * @package spec\Cmp\Cache\Application
17
 * @mixin \Cmp\Cache\Decorator\LoggerCache
18
 */
19
class LoggerCacheSpec extends ObjectBehavior
20
{
21
    function let(CacheDecorator $decorated, LoggerInterface $logger)
22
    {
23
        $this->beConstructedWith($decorated, $withExceptions = true, $logger, LogLevel::CRITICAL);
24
        $decorated->getDecoratedCache()->willReturn($decorated->getWrappedObject());
25
    }
26
27
    function it_is_initializable()
28
    {
29
        $this->shouldHaveType('\Cmp\Cache\Decorator\LoggerCache');
30
        $this->shouldHaveType('\Cmp\Cache\Cache');
31
    }
32
33
    function it_can_return_the_decorated_cache_correctly(Cache $cache)
34
    {
35
        $this->beConstructedWith($cache);
36
        $this->getDecoratedCache()->shouldReturn($cache);
37
    }
38
39
    function it_can_get_the_inner_decorated_cache(CacheDecorator $anotherDecorator, CacheDecorator $decorated)
40
    {
41
        $this->beConstructedWith($anotherDecorator);
42
        $anotherDecorator->getDecoratedCache()->willReturn($decorated);
43
44
        $this->getDecoratedCache()->shouldReturn($decorated);
45
    }
46
47
    function it_delegates_set_operations_correctly(CacheDecorator $decorated)
48
    {
49
        $decorated->set('one', 'foo', 10)->willReturn(true);
50
51
        $exception = new \Exception("Server's on fire!");
52
        $decorated->set('two', 'bar')->willThrow($exception);
53
54
        $this->set('one', 'foo', 10)->shouldBe(true);
55
        $this->shouldThrow('\Cmp\Cache\Exceptions\BackendOperationFailedException')->duringSet('two', 'bar');
56
    }
57
58
    function it_can_work_in_silent_mode(CacheDecorator $decorated)
59
    {
60
        $withExceptions = false;
61
        $this->beConstructedWith($decorated, $withExceptions);
62
63
        $exception = new \Exception("Server's on fire!");
64
        $decorated->set('foo', 'bar')->willThrow($exception);
65
66
        $this->set('foo', 'bar')->shouldReturn(false);
67
    }
68
69
    function it_delegates_get_operations_correctly(CacheDecorator $decorated)
70
    {
71
        $decorated->get('foo', null)->willReturn('bar');
72
73
        $this->get('foo')->shouldReturn('bar');
74
    }
75
76
    function it_delegates_demand_operations_correctly(CacheDecorator $decorated, LoggerInterface $logger)
77
    {
78
        $exception = new NotFoundException('foo');
79
        $decorated->demand('foo')->willThrow($exception);
80
81
        $this->shouldThrow($exception)->duringDemand('foo');
82
83
        $logger->log(LogLevel::CRITICAL, Argument::containingString("cache operation failed"), [
84
            'cache'     => get_class($decorated),
85
            'decorated' => get_class($decorated->getWrappedObject()),
86
            'exception' => $exception,
87
            'method'    => Argument::containingString('demand'),
88
            'arguments' => ['foo'],
89
        ]);
90
    }
91
92
    function it_delegates_has_operations_correctly(CacheDecorator $decorated)
93
    {
94
        $decorated->has('foo')->willReturn(true);
95
96
        $this->has('foo')->shouldReturn(true);
97
    }
98
99
    function it_delegates_delete_operations_correctly(CacheDecorator $decorated)
100
    {
101
        $decorated->delete('foo')->willReturn(false);
102
103
        $this->delete('foo')->shouldReturn(false);
104
    }
105
106
    function it_delegates_delete_all_operations_correctly(CacheDecorator $decorated)
107
    {
108
        $decorated->deleteItems(['foo', 'bar'])->willReturn(true);
109
110
        $this->deleteItems(['foo', 'bar'])->shouldReturn(true);
111
    }
112
113
    function it_delegates_flush_operations_correctly(CacheDecorator $decorated)
114
    {
115
        $decorated->flush()->willReturn(false);
116
117
        $this->flush()->shouldReturn(false);
118
    }
119
120
    function it_delegates_set_items_operations_correctly(CacheDecorator $decorated)
121
    {
122
        $decorated->setItems(['foo' => 'bar'], 10)->willReturn(true);
123
124
        $this->setItems(['foo' => 'bar'], 10)->shouldReturn(true);
125
    }
126
127
    function it_delegates_get_items_operations_correctly(CacheDecorator $decorated)
128
    {
129
        $decorated->getItems(['foo'])->willReturn(['foo' => 'bar']);
130
131
        $this->getItems(['foo'])->shouldReturn(['foo' => 'bar']);
132
    }
133
134
    function it_delegates_get_time_to_live_operations_correctly(CacheDecorator $decorated)
135
    {
136
        $decorated->getTimeToLive('foo')->willReturn(false);
137
138
        $this->getTimeToLive('foo')->shouldReturn(false);
139
    }
140
}
141