Code Duplication    Length = 18-24 lines in 3 locations

tests/FacebookTest.php 3 locations

@@ 200-217 (lines=18) @@
197
        new Facebook($config);
198
    }
199
200
    public function testMcryptCsprgCanBeForced()
201
    {
202
        if (!function_exists('mcrypt_create_iv')) {
203
            $this->markTestSkipped(
204
                'Mcrypt must be installed to test mcrypt_create_iv().'
205
            );
206
        }
207
208
        $config = array_merge($this->config, [
209
            'persistent_data_handler' => 'memory', // To keep session errors from happening
210
            'pseudo_random_string_generator' => 'mcrypt'
211
        ]);
212
        $fb = new Facebook($config);
213
        $this->assertInstanceOf(
214
            'Facebook\PseudoRandomString\McryptPseudoRandomStringGenerator',
215
            $fb->getRedirectLoginHelper()->getPseudoRandomStringGenerator()
216
        );
217
    }
218
219
    public function testOpenSslCsprgCanBeForced()
220
    {
@@ 219-236 (lines=18) @@
216
        );
217
    }
218
219
    public function testOpenSslCsprgCanBeForced()
220
    {
221
        if (!function_exists('openssl_random_pseudo_bytes')) {
222
            $this->markTestSkipped(
223
                'The OpenSSL extension must be enabled to test openssl_random_pseudo_bytes().'
224
            );
225
        }
226
227
        $config = array_merge($this->config, [
228
            'persistent_data_handler' => 'memory', // To keep session errors from happening
229
            'pseudo_random_string_generator' => 'openssl'
230
        ]);
231
        $fb = new Facebook($config);
232
        $this->assertInstanceOf(
233
            'Facebook\PseudoRandomString\OpenSslPseudoRandomStringGenerator',
234
            $fb->getRedirectLoginHelper()->getPseudoRandomStringGenerator()
235
        );
236
    }
237
238
    public function testUrandomCsprgCanBeForced()
239
    {
@@ 238-261 (lines=24) @@
235
        );
236
    }
237
238
    public function testUrandomCsprgCanBeForced()
239
    {
240
        if (ini_get('open_basedir')) {
241
            $this->markTestSkipped(
242
                'Cannot test /dev/urandom generator due to open_basedir constraint.'
243
            );
244
        }
245
246
        if (!is_readable('/dev/urandom')) {
247
            $this->markTestSkipped(
248
                '/dev/urandom not found or is not readable.'
249
            );
250
        }
251
252
        $config = array_merge($this->config, [
253
            'persistent_data_handler' => 'memory', // To keep session errors from happening
254
            'pseudo_random_string_generator' => 'urandom'
255
        ]);
256
        $fb = new Facebook($config);
257
        $this->assertInstanceOf(
258
            'Facebook\PseudoRandomString\UrandomPseudoRandomStringGenerator',
259
            $fb->getRedirectLoginHelper()->getPseudoRandomStringGenerator()
260
        );
261
    }
262
263
    /**
264
     * @expectedException \InvalidArgumentException