示例#1
0
文件: RuleTest.php 项目: minond/http
 public function testHttpMethodsCanBePassedInWithTemplatesAndBeSeparatedByMultipleSpaces()
 {
     $this->rule->setTemplate('GET                  /users');
     $info = $this->rule->getInformation();
     $this->assertTrue(isset($info['method']));
     $this->assertEquals('GET', $info['method']);
 }
示例#2
0
文件: RuleBook.php 项目: minond/http
 /**
  * add multiple rules
  * @param array|object $rules
  * @param is_template, default: false
  * @throws DuplicateRuleException
  * @throws InvalidArgumentException
  */
 public function load($rules, $is_template = false)
 {
     if (is_object($rules) || is_array($rules)) {
         foreach ($rules as $route => $info) {
             $rule = Rule::create($route, $info, $is_template);
             $this->add($rule);
         }
     } else {
         throw new \InvalidArgumentException('First argument must be an array or an object');
     }
 }
示例#3
0
 public function testRuleIsSavedToRequest()
 {
     $req = new Request();
     $req->setMethod(Verb::GET);
     $req->setUri('/mypage');
     $rand = mt_rand();
     $rule = Rule::create('/mypage', ['random' => $rand], true);
     $this->rulebook->add($rule);
     $this->rulebook->matching($req, true);
     $this->assertEquals($rule, $req->getRule());
 }