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

OpenSSLCryptoTest::testIntegrity()   A

Complexity

Conditions 2
Paths 2

Size

Total Lines 13

Duplication

Lines 5
Ratio 38.46 %

Importance

Changes 0
Metric Value
dl 5
loc 13
rs 9.8333
c 0
b 0
f 0
cc 2
nc 2
nop 0
1
<?php
2
3
namespace SilverStripe\HybridSessions\Tests;
4
5
use SilverStripe\Dev\SapphireTest;
6
use SilverStripe\HybridSessions\Crypto\OpenSSLCrypto;
7
8
/**
9
 * @requires extension openssl
10
 */
11
class OpenSSLCryptoTest extends SapphireTest
12
{
13
    public function testIntegrity()
14
    {
15
        $key = random_bytes(8);
16
        $salt = random_bytes(16);
17
18
        $handler = new OpenSSLCrypto($key, $salt);
19
20 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...
21
            $data = random_bytes(1024 * 4);
22
23
            $this->assertEquals($data, $handler->decrypt($handler->encrypt($data)));
24
        }
25
    }
26
}
27