public function testHttpMethodsCanBePassedInWithTemplatesAndBeSeparatedByMultipleSpaces() { $this->rule->setTemplate('GET /users'); $info = $this->rule->getInformation(); $this->assertTrue(isset($info['method'])); $this->assertEquals('GET', $info['method']); }
/** * 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'); } }
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()); }