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

FactoryTest   A

Complexity

Total Complexity 4

Size/Duplication

Total Lines 39
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 4

Importance

Changes 1
Bugs 0 Features 0
Metric Value
wmc 4
c 1
b 0
f 0
lcom 1
cbo 4
dl 0
loc 39
rs 10
1
<?php
2
3
namespace RandomLib;
4
5
use SecurityLib\Strength;
6
7
class FactoryTest extends \PHPUnit_Framework_TestCase {
8
9
    public function testConstruct() {
10
        $factory = new Factory;
11
        $this->assertTrue($factory instanceof Factory);
12
    }
13
14
    public function testGetGeneratorFallback() {
15
        $factory = new Factory;
16
        $generator = $factory->getGenerator(new Strength(Strength::VERYLOW));
17
        $mixer = call_user_func(array(
18
            get_class($generator->getMixer()),
19
            'getStrength'
20
        ));
21
        $this->assertTrue($mixer->compare(new Strength(Strength::LOW)) <= 0);
22
    }
23
24
    /**
25
     * @covers RandomLib\Factory::getMediumStrengthGenerator
26
     * @covers RandomLib\Factory::getGenerator
27
     * @covers RandomLib\Factory::findMixer
28
     */
29
    public function testGetMediumStrengthGenerator() {
30
        $factory = new Factory;
31
        $generator = $factory->getMediumStrengthGenerator();
32
        $this->assertTrue($generator instanceof Generator);
33
        $mixer = call_user_func(array(
34
            get_class($generator->getMixer()),
35
            'getStrength'
36
        ));
37
        $this->assertTrue($mixer->compare(new Strength(Strength::MEDIUM)) <= 0);
38
        foreach ($generator->getSources() as $source) {
39
            $strength = call_user_func(array(get_class($source), 'getStrength'));
40
            $this->assertTrue($strength->compare(new Strength(Strength::MEDIUM)) >= 0);
41
        }
42
    }
43
44
45
}
46