Code Duplication    Length = 18-20 lines in 5 locations

Tests/RedisLockStrategyTest.php 5 locations

@@ 101-118 (lines=18) @@
98
    /**
99
     * @test
100
     */
101
    public function shouldConnectAndAcquireALock()
102
    {
103
        $id = uniqid();
104
105
        $GLOBALS['TYPO3_CONF_VARS']['SYS']['redis_lock'] = [
106
            'host'     => $this->redisHost,
107
            'port'     => 6379,
108
            'database' => $this->redisDatabase,
109
        ];
110
111
        $locker = $this->lockFactory->createLocker($id);
112
113
        $redis = $this->getRedisClient();
114
115
        $redis->set($id, 'testvalue');
116
117
        self::assertTrue($locker->acquire());
118
    }
119
120
121
    /**
@@ 124-141 (lines=18) @@
121
    /**
122
     * @test
123
     */
124
    public function shouldConnectAndAcquireAExistingLock()
125
    {
126
        $id = uniqid();
127
128
        $GLOBALS['TYPO3_CONF_VARS']['SYS']['redis_lock'] = [
129
            'host'     => $this->redisHost,
130
            'port'     => 6379,
131
            'database' => $this->redisDatabase,
132
        ];
133
134
        $locker = $this->lockFactory->createLocker($id);
135
136
        self::assertTrue($locker->acquire());
137
138
        $redis = $this->getRedisClient();
139
140
        self::assertTrue($redis->exists($id));
141
    }
142
143
    /**
144
     * @test
@@ 146-163 (lines=18) @@
143
    /**
144
     * @test
145
     */
146
    public function shouldConnectAndCheckIfLockIsAcquired()
147
    {
148
        $id = uniqid();
149
150
        $GLOBALS['TYPO3_CONF_VARS']['SYS']['redis_lock'] = [
151
            'host'     => $this->redisHost,
152
            'port'     => 6379,
153
            'database' => $this->redisDatabase,
154
        ];
155
156
        $locker = $this->lockFactory->createLocker($id);
157
158
        $redis = $this->getRedisClient();
159
160
        $redis->set($id, 'testvalue');
161
162
        self::assertTrue($locker->isAcquired());
163
    }
164
165
    /**
166
     * @test
@@ 168-187 (lines=20) @@
165
    /**
166
     * @test
167
     */
168
    public function shouldConnectAndDestroyALock()
169
    {
170
        $id = uniqid();
171
172
        $GLOBALS['TYPO3_CONF_VARS']['SYS']['redis_lock'] = [
173
            'host'     => $this->redisHost,
174
            'port'     => 6379,
175
            'database' => $this->redisDatabase,
176
        ];
177
178
        $locker = $this->lockFactory->createLocker($id);
179
180
        $redis = $this->getRedisClient();
181
182
        $redis->set($id, 'testvalue');
183
184
        $locker->destroy();
185
186
        self::assertFalse($redis->exists($id));
187
    }
188
189
    /**
190
     * @test
@@ 192-209 (lines=18) @@
189
    /**
190
     * @test
191
     */
192
    public function shouldConnectAndDestroyANotExistingLock()
193
    {
194
        $id = uniqid();
195
196
        $GLOBALS['TYPO3_CONF_VARS']['SYS']['redis_lock'] = [
197
            'host'     => $this->redisHost,
198
            'port'     => 6379,
199
            'database' => $this->redisDatabase,
200
        ];
201
202
        $locker = $this->lockFactory->createLocker($id);
203
204
        $redis = $this->getRedisClient();
205
206
        $locker->destroy();
207
208
        self::assertFalse($redis->exists($id));
209
    }
210
211
    protected function setUp()
212
    {