Completed
Push — master ( 3d39f9...d9b5c0 )
by Anthony
07:02 queued 04:32
created

McryptRijndael128Test   A

Complexity

Total Complexity 7

Size/Duplication

Total Lines 48
Duplicated Lines 100 %

Coupling/Cohesion

Components 0
Dependencies 3

Importance

Changes 1
Bugs 0 Features 1
Metric Value
wmc 7
c 1
b 0
f 1
lcom 0
cbo 3
dl 48
loc 48
rs 10

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 RandomLib\Mixer;
4
5
use SecurityLib\Strength;
6
7
class McryptRijndael128Test extends \PHPUnit_Framework_TestCase {
8
9
    public static function provideMix() {
10
        $data = array(
11
            array(array(), ''),
12
            array(array('', ''), ''),
13
            array(array('a'), '61'),
14
            array(array('a', 'b'), '6a'),
15
            array(array('aa', 'ba'), '688d'),
16
            array(array('ab', 'bb'), 'f8bc'),
17
            array(array('aa', 'bb'), 'a0f3'),
18
            array(array('aa', 'bb', 'cc'), '87c3'),
19
            array(array('aabbcc', 'bbccdd', 'ccddee'), '7cf2273e46c7'),
20
        );
21
        return $data;
22
    }
23
24
    protected function setUp() {
25
        if (!extension_loaded('mcrypt')) {
26
            $this->markTestSkipped('mcrypt extension is not available');
27
        }
28
    }
29
30
    public function testConstructWithoutArgument() {
31
        $hash = new McryptRijndael128;
32
        $this->assertTrue($hash instanceof \RandomLib\Mixer);
33
    }
34
35
    public function testGetStrength() {
36
        $strength = new Strength(Strength::HIGH);
37
        $actual = McryptRijndael128::getStrength();
38
        $this->assertEquals($actual, $strength);
39
    }
40
41
    public function testTest() {
42
        $actual = McryptRijndael128::test();
43
        $this->assertTrue($actual);
44
    }
45
46
    /**
47
     * @dataProvider provideMix
48
     */
49
    public function testMix($parts, $result) {
50
        $mixer = new McryptRijndael128;
51
        $actual = $mixer->mix($parts);
52
        $this->assertEquals($result, bin2hex($actual));
53
    }
54
}
55