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 ( b12a1e...5e31f9 )
by Hilari
02:47
created

FeatureContextBackup   A

Complexity

Total Complexity 13

Size/Duplication

Total Lines 116
Duplicated Lines 0 %

Coupling/Cohesion

Components 2
Dependencies 1

Importance

Changes 0
Metric Value
wmc 13
lcom 2
cbo 1
dl 0
loc 116
rs 10
c 0
b 0
f 0

11 Methods

Rating   Name   Duplication   Size   Complexity  
A __construct() 0 6 1
A reset() 0 4 1
A theCacheIsEmpty() 0 4 1
A iStoreAAnItemInTheCache() 0 4 1
A whenIRetrieved() 0 4 1
A iShouldGetTheSameItem() 0 6 2
A iStoreAAnItemInTheCacheForSecond() 0 4 1
A iWaitSeconds() 0 4 1
A iShouldNotBeAbleToRetrieveIt() 0 6 2
A iDeleteTheItemFromTheCache() 0 4 1
A iFlushAllTheItemsItemFromTheCache() 0 4 1
1
<?php
2
3
namespace Cmp\Cache\Tests;
4
5
use Behat\Behat\Context\SnippetAcceptingContext;
6
use Cmp\Cache\Infrastructure\RedisCache;
7
8
class FeatureContextBackup implements SnippetAcceptingContext
9
{
10
    /**
11
     * @var \Redis
12
     */
13
    private $redis;
14
15
    /**
16
     * @var RedisCache
17
     */
18
    private $backend;
19
20
    /**
21
     * @var string
22
     */
23
    private $result;
24
25
    /**
26
     * FeatureContext constructor.
27
     */
28
    public function __construct()
29
    {
30
        $this->redis = new \Redis();
31
        $this->redis->connect($_SERVER['REDIS_HOST'], 6379);
32
        $this->backend = new RedisCache($this->redis); 
33
    }
34
35
    /**
36
     * @BeforeScenario
37
     */
38
    public function reset()
39
    {
40
        $this->redis->flushDB();
41
    }
42
43
    /**
44
     * @Given The cache is empty
45
     */
46
    public function theCacheIsEmpty()
47
    {
48
        $this->redis->flushDB();
49
    }
50
51
    /**
52
     * @Given I store a an item in the cache
53
     */
54
    public function iStoreAAnItemInTheCache()
55
    {
56
        $this->backend->set('foo', 'bar');
57
    }
58
59
    /**
60
     * @When I retrieve it
61
     */
62
    public function whenIRetrieved()
63
    {
64
        $this->result = $this->backend->get('foo');
65
    }
66
67
    /**
68
     * @Then I should get the same item
69
     */
70
    public function iShouldGetTheSameItem()
71
    {
72
        if ($this->result !== 'bar') {
73
            throw new \RuntimeException("The retrieve item is not the same");
74
        }
75
    }
76
77
    /**
78
     * @param $timeToLive
79
     * 
80
     * @Given I store a an item in the cache for :timeToLive second
81
     */
82
    public function iStoreAAnItemInTheCacheForSecond($timeToLive)
83
    {
84
        $this->backend->set('foo', 'bar', $timeToLive);
85
    }
86
87
    /**
88
     * @param $seconds
89
     * 
90
     * @When I wait :seconds seconds
91
     */
92
    public function iWaitSeconds($seconds)
93
    {
94
        sleep($seconds);
95
    }
96
97
    /**
98
     * @Then I should not be able to retrieve it
99
     */
100
    public function iShouldNotBeAbleToRetrieveIt()
101
    {
102
        if ($this->backend->has('foo')) {
103
            throw new \RuntimeException("Redis still has the item stored");
104
        }
105
    }
106
107
    /**
108
     * @When I delete the item from the cache
109
     */
110
    public function iDeleteTheItemFromTheCache()
111
    {
112
        $this->backend->delete('foo');
113
    }
114
115
    /**
116
     * @When I flush all the items item from the cache
117
     */
118
    public function iFlushAllTheItemsItemFromTheCache()
119
    {
120
        $this->backend->flush();
121
    }
122
123
}