Development

Changeset 7515

You must first sign up to be able to contribute.

Changeset 7515

Show
Ignore:
Timestamp:
02/16/08 15:40:01 (9 months ago)
Author:
fabien
Message:

added some unit tests for sfPatternRouting

Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • branches/1.1/test/unit/routing/sfPatternRoutingTest.php

    r7364 r7515  
    1111require_once(dirname(__FILE__).'/../../bootstrap/unit.php'); 
    1212 
    13 $t = new lime_test(70, new lime_output_color()); 
     13$t = new lime_test(73, new lime_output_color()); 
    1414 
    1515class sfPatternRoutingTest extends sfPatternRouting 
     
    160160//$t->is($r->generate('', $params), $url, '->generate() removes the last parameter if the parameter is default value'); 
    161161 
    162 // Numerics params 
     162// numerics params 
    163163$r->clearRoutes(); 
    164164$r->connect('test', '/:module/:action/*', array('module' => 'default', 'action' => 'index')); 
     
    292292$r->parse('/module/action/2'); 
    293293$t->is($r->getCurrentInternalUri(true), '@test2?id=2', '->getCurrentInternalUri() returns the internal URI for last parsed URL'); 
     294 
    294295// these tests are against r7363 
    295296$t->is($r->getCurrentInternalUri(false), 'foo/bar?id=2', '->getCurrentInternalUri() returns the internal URI for last parsed URL'); 
    296297$t->is($r->getCurrentInternalUri(true), '@test2?id=2', '->getCurrentInternalUri() returns the internal URI for last parsed URL'); 
    297298$t->is($r->getCurrentInternalUri(false), 'foo/bar?id=2', '->getCurrentInternalUri() returns the internal URI for last parsed URL'); 
     299 
     300// defaults 
     301$t->diag('defaults'); 
     302$r->clearRoutes(); 
     303$r->connect('test', '/test', array('module' => 'default', 'action' => 'index', 'bar' => 'foo')); 
     304$params = array('module' => 'default', 'action' => 'index'); 
     305$url = '/test'; 
     306$t->is($r->generate('', $params), $url, '->generate() routes takes default values into account when matching a route'); 
     307$params = array('module' => 'default', 'action' => 'index', 'bar' => 'foo'); 
     308$t->is($r->generate('', $params), $url, '->generate() routes takes default values into account when matching a route'); 
     309$params = array('module' => 'default', 'action' => 'index', 'bar' => 'bar'); 
     310try 
     311{ 
     312  $r->generate('', $params); 
     313  $t->fail('->generate() throws a sfConfigurationException if no route matches the params'); 
     314} 
     315catch (sfConfigurationException $e) 
     316{ 
     317  $t->pass('->generate() throws a sfConfigurationException if no route matches the params'); 
     318}