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 should_connect_and_acquire_a_lock()
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
     * @return \Redis
@@ 135-152 (lines=18) @@
132
    /**
133
     * @test
134
     */
135
    public function should_connect_and_acquire_a_existing_lock()
136
    {
137
        $id = uniqid();
138
139
        $GLOBALS['TYPO3_CONF_VARS']['SYS']['redis_lock'] = [
140
            'host'     => $this->redisHost,
141
            'port'     => 6379,
142
            'database' => $this->redisDatabase,
143
        ];
144
145
        $locker = $this->lockFactory->createLocker($id);
146
147
        self::assertTrue($locker->acquire());
148
149
        $redis = $this->getRedisClient();
150
151
        self::assertTrue($redis->exists($id));
152
    }
153
154
    /**
155
     * @test
@@ 157-174 (lines=18) @@
154
    /**
155
     * @test
156
     */
157
    public function should_connect_and_check_if_lock_is_acquired()
158
    {
159
        $id = uniqid();
160
161
        $GLOBALS['TYPO3_CONF_VARS']['SYS']['redis_lock'] = [
162
            'host'     => $this->redisHost,
163
            'port'     => 6379,
164
            'database' => $this->redisDatabase,
165
        ];
166
167
        $locker = $this->lockFactory->createLocker($id);
168
169
        $redis = $this->getRedisClient();
170
171
        $redis->set($id, 'testvalue');
172
173
        self::assertTrue($locker->isAcquired());
174
    }
175
176
    /**
177
     * @test
@@ 179-198 (lines=20) @@
176
    /**
177
     * @test
178
     */
179
    public function should_connect_and_destroy_a_lock()
180
    {
181
        $id = uniqid();
182
183
        $GLOBALS['TYPO3_CONF_VARS']['SYS']['redis_lock'] = [
184
            'host'     => $this->redisHost,
185
            'port'     => 6379,
186
            'database' => $this->redisDatabase,
187
        ];
188
189
        $locker = $this->lockFactory->createLocker($id);
190
191
        $redis = $this->getRedisClient();
192
193
        $redis->set($id, 'testvalue');
194
195
        $locker->destroy();
196
197
        self::assertFalse($redis->exists($id));
198
    }
199
200
    /**
201
     * @test
@@ 203-220 (lines=18) @@
200
    /**
201
     * @test
202
     */
203
    public function should_connect_and_destroy_a_not_existing_lock()
204
    {
205
        $id = uniqid();
206
207
        $GLOBALS['TYPO3_CONF_VARS']['SYS']['redis_lock'] = [
208
            'host'     => $this->redisHost,
209
            'port'     => 6379,
210
            'database' => $this->redisDatabase,
211
        ];
212
213
        $locker = $this->lockFactory->createLocker($id);
214
215
        $redis = $this->getRedisClient();
216
217
        $locker->destroy();
218
219
        self::assertFalse($redis->exists($id));
220
    }
221
222
    protected function setUp()
223
    {