| 1 | <?php |
||
| 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 |