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

RandTest::provideGenerate()   A

Complexity

Conditions 3
Paths 3

Size

Total Lines 8
Code Lines 6

Duplication

Lines 8
Ratio 100 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
c 1
b 0
f 0
dl 8
loc 8
rs 9.4285
nc 3
cc 3
eloc 6
nop 0
1
<?php
2
3
namespace RandomLib\Source;
4
5
use SecurityLib\Strength;
6
7
class RandTest extends \PHPUnit_Framework_TestCase {
8
9
    public static function provideGenerate() {
10
        $data = array();
11
        for ($i = 0; $i < 100; $i += 5) {
12
            $not = $i > 0 ? str_repeat(chr(0), $i) : chr(0);
13
            $data[] = array($i, $not);
14
        }
15
        return $data;
16
    }
17
18
    /**
19
     */
20
    public function testGetStrength() {
21
        if (defined('S_ALL')) {
22
            $strength = new Strength(Strength::LOW);
23
        } else {
24
            $strength = new Strength(Strength::VERYLOW);
25
        }
26
        $actual = Rand::getStrength();
27
        $this->assertEquals($actual, $strength);
28
    }
29
30
    /**
31
     * @dataProvider provideGenerate
32
     */
33
    public function testGenerate($length, $not) {
34
        $rand = new Rand;
35
        $stub = $rand->generate($length);
36
        $this->assertEquals($length, strlen($stub));
37
        $this->assertNotEquals($not, $stub);
38
    }
39
40
}
41