Example #1
0
 public function testGenerateWithMulipleLiterals()
 {
     $literal = new LiteralScope('scope1');
     $literal->addLiteral('a');
     $literal->addLiteral('b');
     $literal->addLiteral('c');
     $literal->addLiteral('d');
     $literal->setMinOccurances(1);
     $literal->setMaxOccurances(4);
     $gen = new \ReverseRegex\Random\SrandRandom(0);
     $result = '';
     $literal->generate($result, $gen);
     $this->assertLessThanOrEqual(4, strlen($result));
     $this->assertGreaterThanOrEqual(1, strlen($result));
 }
Example #2
0
 public function testGenerateWithAlternatingStrategy()
 {
     $scope = new Scope('scope1');
     $gen = new MersenneRandom(700);
     $result = '';
     $scope->setMinOccurances(7);
     $scope->setMaxOccurances(7);
     for ($i = 1; $i <= 6; $i++) {
         $lit = new LiteralScope('label_' . $i);
         $lit->addLiteral($i);
         $scope->attach($lit);
         $lit = null;
     }
     $scope->useAlternatingStrategy();
     $scope->generate($result, $gen);
     $this->assertRegExp('/[1-6]{7}/', $result);
 }