Changeset 20472
- Timestamp:
- 07/24/09 21:25:20 (4 years ago)
- Files:
-
- branches/1.2/lib/routing/sfRequestRoute.class.php (modified) (4 diffs)
- branches/1.2/test/unit/routing/sfRequestRouteTest.php (modified) (2 diffs)
- branches/1.3/lib/routing/sfRequestRoute.class.php (modified) (4 diffs)
- branches/1.3/test/unit/routing/sfRequestRouteTest.php (modified) (2 diffs)
Legend:
- Unmodified
- Added
- Removed
- Modified
- Copied
- Moved
branches/1.2/lib/routing/sfRequestRoute.class.php
r20469 r20472 34 34 $requirements['sf_method'] = array('get', 'head'); 35 35 } 36 else if (!is_array($requirements['sf_method']))36 else 37 37 { 38 $requirements['sf_method'] = array ($requirements['sf_method']);38 $requirements['sf_method'] = array_map('strtolower', (array) $requirements['sf_method']); 39 39 } 40 40 … … 58 58 59 59 // enforce the sf_method requirement 60 foreach ($this->requirements['sf_method'] as $method)60 if (in_array(strtolower($context['method']), $this->requirements['sf_method'])) 61 61 { 62 if (0 == strcasecmp($method, $context['method'])) 63 { 64 return $parameters; 65 } 62 return $parameters; 66 63 } 67 64 … … 70 67 71 68 /** 72 * Returns true if the parameters match esthis route, false otherwise.69 * Returns true if the parameters match this route, false otherwise. 73 70 * 74 71 * @param mixed $params The parameters … … 82 79 { 83 80 // enforce the sf_method requirement 84 if (!in_array( $params['sf_method'], $this->requirements['sf_method']))81 if (!in_array(strtolower($params['sf_method']), $this->requirements['sf_method'])) 85 82 { 86 83 return false; branches/1.2/test/unit/routing/sfRequestRouteTest.php
r20469 r20472 11 11 require_once(dirname(__FILE__).'/../../bootstrap/unit.php'); 12 12 13 $t = new lime_test( 4, new lime_output_color());13 $t = new lime_test(8, new lime_output_color()); 14 14 15 15 // ->__construct() … … 33 33 $route = new sfRequestRoute('/', array(), array('sf_method' => array('get', 'head'))); 34 34 $t->ok($route->matchesParameters(array('sf_method' => 'get')), '->matchesParameters() matches the "sf_method" parameter'); 35 36 $route = new sfRequestRoute('/', array(), array('sf_method' => array('get'))); 37 $t->ok($route->matchesParameters(array('sf_method' => 'GET')), '->matchesParameters() checks "sf_method" requirement case-insensitively'); 38 39 $route = new sfRequestRoute('/', array(), array('sf_method' => array('GET'))); 40 $t->ok($route->matchesParameters(array('sf_method' => 'get')), '->matchesParameters() checks "sf_method" requirement case-insensitively'); 41 42 // ->matchesUrl() 43 $t->diag('->matchesUrl()'); 44 45 $route = new sfRequestRoute('/', array(), array('sf_method' => 'GET')); 46 $t->isa_ok($route->matchesUrl('/', array('method' => 'get')), 'array', '->matchesUrl() check "sf_method" requirement case-insensitively'); 47 48 $route = new sfRequestRoute('/', array(), array('sf_method' => 'get')); 49 $t->isa_ok($route->matchesUrl('/', array('method' => 'GET')), 'array', '->matchesUrl() check "sf_method" requirement case-insensitively'); branches/1.3/lib/routing/sfRequestRoute.class.php
r20469 r20472 34 34 $requirements['sf_method'] = array('get', 'head'); 35 35 } 36 else if (!is_array($requirements['sf_method']))36 else 37 37 { 38 $requirements['sf_method'] = array ($requirements['sf_method']);38 $requirements['sf_method'] = array_map('strtolower', (array) $requirements['sf_method']); 39 39 } 40 40 … … 58 58 59 59 // enforce the sf_method requirement 60 foreach ($this->requirements['sf_method'] as $method)60 if (in_array(strtolower($context['method']), $this->requirements['sf_method'])) 61 61 { 62 if (0 == strcasecmp($method, $context['method'])) 63 { 64 return $parameters; 65 } 62 return $parameters; 66 63 } 67 64 … … 70 67 71 68 /** 72 * Returns true if the parameters match esthis route, false otherwise.69 * Returns true if the parameters match this route, false otherwise. 73 70 * 74 71 * @param mixed $params The parameters … … 82 79 { 83 80 // enforce the sf_method requirement 84 if (!in_array( $params['sf_method'], $this->requirements['sf_method']))81 if (!in_array(strtolower($params['sf_method']), $this->requirements['sf_method'])) 85 82 { 86 83 return false; branches/1.3/test/unit/routing/sfRequestRouteTest.php
r20469 r20472 11 11 require_once(dirname(__FILE__).'/../../bootstrap/unit.php'); 12 12 13 $t = new lime_test( 4, new lime_output_color());13 $t = new lime_test(8, new lime_output_color()); 14 14 15 15 // ->__construct() … … 33 33 $route = new sfRequestRoute('/', array(), array('sf_method' => array('get', 'head'))); 34 34 $t->ok($route->matchesParameters(array('sf_method' => 'get')), '->matchesParameters() matches the "sf_method" parameter'); 35 36 $route = new sfRequestRoute('/', array(), array('sf_method' => array('get'))); 37 $t->ok($route->matchesParameters(array('sf_method' => 'GET')), '->matchesParameters() checks "sf_method" requirement case-insensitively'); 38 39 $route = new sfRequestRoute('/', array(), array('sf_method' => array('GET'))); 40 $t->ok($route->matchesParameters(array('sf_method' => 'get')), '->matchesParameters() checks "sf_method" requirement case-insensitively'); 41 42 // ->matchesUrl() 43 $t->diag('->matchesUrl()'); 44 45 $route = new sfRequestRoute('/', array(), array('sf_method' => 'GET')); 46 $t->isa_ok($route->matchesUrl('/', array('method' => 'get')), 'array', '->matchesUrl() check "sf_method" requirement case-insensitively'); 47 48 $route = new sfRequestRoute('/', array(), array('sf_method' => 'get')); 49 $t->isa_ok($route->matchesUrl('/', array('method' => 'GET')), 'array', '->matchesUrl() check "sf_method" requirement case-insensitively');