Created
August 17, 2011 17:00
-
-
Save ringmaster/1152018 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/** | |
* Test matching routes based on HTTP method verbs. | |
*/ | |
public function testMethodBasedMatching() { | |
$parameters = array('controller' => 'users', 'action' => 'edit'); | |
$route = new Route(array( | |
'template' => '/method', | |
'params' => $parameters + array('http:method' => 'POST') | |
)); | |
$this->assertFalse($route->match($parameters)); | |
$this->assertEqual('/method', $route->match($parameters + array('http:method' => 'POST'))); | |
$route = new Route(array( | |
'template' => '/method/{:controller}/{:id:[0-9]+}', | |
'params' => $parameters + array('http:method' => array('POST', 'PUT')) | |
)); | |
$this->assertFalse($route->match($parameters)); | |
$this->assertFalse($route->match($parameters + array('id' => '54'))); | |
$this->assertFalse($route->match($parameters + array('id' => '54') + array('http:method' => 'GET'))); | |
$this->assertEqual('/method/users/54', $route->match($parameters + array('id' => '54') + array('http:method' => 'POST'))); | |
$this->assertEqual('/method/users/54', $route->match($parameters + array('id' => '54') + array('http:method' => 'PUT'))); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment