Beispiel #1
0
 public function testDuplicateRuleExceptionsIncludeRuleObjectThatTriggeredError()
 {
     $one = Rule::create(Rule::transpile('/api/{model}/{id}'), ['model' => '...']);
     $two = Rule::create('/api\\/(?P<model>[A-Za-z]+)/', ['model' => '...']);
     try {
         $this->rulebook->add($one);
         $this->rulebook->add($two);
     } catch (DuplicateRuleException $e) {
         $this->assertEquals($two, $e->getRule());
     } catch (Exception $e) {
         $this->fail();
     }
 }
Beispiel #2
0
 public function testTemplateSetterTranspilesToExpression()
 {
     $template = '/list/{country}/{state}';
     $this->rule->setTemplate($template);
     $this->assertEquals($template, $this->rule->getTemplate());
     $this->assertEquals(Rule::transpile($template), $this->rule->getExpression());
 }