Completed
Push — master ( 5d89d9...b6c216 )
by Robbie
15s queued 10s
created

McryptCryptoTest   A

Complexity

Total Complexity 2

Size/Duplication

Total Lines 27
Duplicated Lines 18.52 %

Coupling/Cohesion

Components 0
Dependencies 2

Importance

Changes 0
Metric Value
wmc 2
lcom 0
cbo 2
dl 5
loc 27
rs 10
c 0
b 0
f 0

1 Method

Rating   Name   Duplication   Size   Complexity  
A testIntegrity() 5 24 2

How to fix   Duplicated Code   

Duplicated Code

Duplicate code is one of the most pungent code smells. A rule that is often used is to re-structure code once it is duplicated in three or more places.

Common duplication problems, and corresponding solutions are:

1
<?php
2
3
namespace SilverStripe\HybridSessions\Tests;
4
5
use SilverStripe\Dev\SapphireTest;
6
use SilverStripe\HybridSessions\Crypto\McryptCrypto;
7
8
/**
9
 * @requires extension mcrypt
10
 * @skip
11
 */
12
class McryptCryptoTest extends SapphireTest
13
{
14
    public function testIntegrity()
15
    {
16
        $this->markTestSkipped(
17
            'McryptCrypto is losing zero bytes at the end of messages: ' .
18
            'https://github.com/silverstripe/silverstripe-hybridsessions/issues/53'
19
        );
20
21
        $error_reporting = ini_set('error_reporting', (int) ini_get('error_reporting') & ~E_DEPRECATED);
22
23
        try {
24
            $key = random_bytes(8);
25
            $salt = random_bytes(16);
26
27
            $handler = new McryptCrypto($key, $salt);
28
29 View Code Duplication
            for ($i = 0; $i < 1000; ++$i) {
0 ignored issues
show
Duplication introduced by
This code seems to be duplicated across your project.

Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation.

You can also find more detailed suggestions in the “Code” section of your repository.

Loading history...
30
                $data = random_bytes(1024 * 4);
31
32
                $this->assertEquals($data, $handler->decrypt($handler->encrypt($data)));
33
            }
34
        } finally {
35
            ini_set('error_reporting', $error_reporting);
36
        }
37
    }
38
}
39