コード例 #1
0
ファイル: ConditionTest.php プロジェクト: newairhost/HTRouter
 function setUp()
 {
     $this->_condition = new Condition('%{REQUEST_FILENAME}', '!-f', '[NV]');
     $this->_request = new \HTRouter\Request();
     $this->_request->setFilename("foo");
     $this->_request->setDocumentRoot("/www");
     $this->_request->setHostname("php.unittest.org");
 }
コード例 #2
0
ファイル: RuleTest.php プロジェクト: newairhost/HTRouter
 function testDoesMatchingWithConditionsFunction()
 {
     // Rule does not match, since port != 1337
     $rule = new Rule(".+", "test.php", "");
     $rule->addCondition(new Condition('%{SERVER_ADMIN}', '=info@example.org', ''));
     $rule->addCondition(new Condition('%{SERVER_PORT}', '=1337', ''));
     $result = $rule->rewrite($this->_request);
     $this->assertEquals(0, $result->rc);
     $this->assertEquals("/test.php", $this->_request->getFilename());
     // Rule matches, since info@example.org is correct, and we need OR
     $rule = new Rule(".+", "test.php", "");
     $rule->addCondition(new Condition('%{SERVER_ADMIN}', '=info@example.org', '[OR]'));
     $rule->addCondition(new Condition('%{SERVER_PORT}', '=1337', ''));
     $result = $rule->rewrite($this->_request);
     //$this->assertTrue($rule->matches());
     // Rule matches, since both conditions are true
     $rule = new Rule(".+", "test.php", "");
     $rule->addCondition(new Condition('%{SERVER_ADMIN}', '=info@example.org', ''));
     $rule->addCondition(new Condition('%{SERVER_PORT}', '=80', ''));
     $result = $rule->rewrite($this->_request);
     //$this->assertTrue($rule->matches());
 }
コード例 #3
0
ファイル: SubstTest.php プロジェクト: newairhost/HTRouter
 function testSubstitution_013()
 {
     $this->_request->setUri("blaat");
     $_SERVER['SCRIPT_FILENAME'] = "foo.php";
     $this->assertEquals("blaat foo.php true off", Rule::expandSubstitutions("%{REQUEST_URI} %{REQUEST_FILENAME} %{IS_SUBREQ} %{HTTPS}", $this->_request));
 }