public function testGeneratesAGeneratedValueObject() { $generator = new MapGenerator(function ($n) { return $n * 2; }, ConstantGenerator::box(1)); $this->assertEquals(2, $generator->__invoke($this->size, $this->rand)->unbox()); }
/** * @expectedException LogicException */ public function testGivesUpGenerationIfTheFilterIsNotSatisfiedTooManyTimes() { $generator = new SuchThatGenerator(function ($n) { return $n % 2 == 0; }, ConstantGenerator::box(11)); $generator->__invoke($this->size, $this->rand); }
public function testGeneratesAGeneratedValueObject() { $generator = new BindGenerator(ConstantGenerator::box(4), function ($n) { return new ChooseGenerator($n, $n + 10); }); $this->assertInternalType('integer', $generator->__invoke($this->size, $this->rand)->unbox()); }
/** * @expectedException DomainException */ public function testShrinkOnlyAcceptsElementsOfTheDomainAsParameters() { $generator = new ConstantGenerator(5); $generator->shrink(GeneratedValue::fromJustValue(10)); }