Changeset 924
- Timestamp:
- 07/22/08 16:24:59 (3 months ago)
- Files:
-
- branches/kaste/PHPUnit_TestSuite/examples/RoutingTest.php (modified) (1 diff)
- branches/kaste/PHPUnit_TestSuite/lib/PHPUnit_Routing_TestCase.php (modified) (3 diffs)
- branches/kaste/PHPUnit_TestSuite/tests/fixtures/routes.php (modified) (1 diff)
- branches/kaste/PHPUnit_TestSuite/tests/lib/RoutingTest.php (modified) (2 diffs)
Legend:
- Unmodified
- Added
- Removed
- Modified
- Copied
- Moved
branches/kaste/PHPUnit_TestSuite/examples/RoutingTest.php
r918 r924 8 8 function testStandardRoute() 9 9 { 10 $this->get('/blog/index'); 10 // after parametrizing the url, check if the router 11 // can build the same given url from these parameters 12 $this->checkReciprocity(); 13 14 $this->get('/blog'); 11 15 $this->assertController('blog'); 12 16 $this->assertAction('index'); branches/kaste/PHPUnit_TestSuite/lib/PHPUnit_Routing_TestCase.php
r918 r924 46 46 } 47 47 48 function testReciprocity($bool = true)48 function checkReciprocity($bool = true) 49 49 { 50 50 return $this->reciprocity = $bool; … … 60 60 try { 61 61 $this->params = $this->Router->match($Request); 62 if ($this->reciprocity){ 63 $this->assertEquals($url, $this->Router->urlize($this->params)->path()); 64 } 62 65 }catch (NoMatchingRouteException $e){ 63 66 $this->errors = true; 64 }65 #$this->params = $this->Router->match($url);66 if ($this->reciprocity && $this->params){67 $this->assertEquals($this->encloseWithSlashes($url), $this->Router->toUrl($this->params));68 67 } 69 68 return $this; … … 81 80 82 81 return $Request; 83 }84 85 private function encloseWithSlashes($string)86 {87 return $string == '/' || $string == '' ? '/' : '/'.trim($string,'/').'/';88 82 } 89 83 branches/kaste/PHPUnit_TestSuite/tests/fixtures/routes.php
r920 r924 5 5 $Map->connect('/', array('controller' => 'page', 'action' => 'index')); 6 6 $Map->connect('/:artist/:album/tags',array('controller'=>'tags')); 7 $Map->connect('/admin/logs/:controller/:action/:id',array('module'=>'admin/logs')); 7 $Map->connect('/admin/logs/:type',array('module'=>'admin','controller'=>'logs','action'=>'list','type'=>'all')); 8 $Map->connect('/admin/:controller/:action/:id',array('module'=>'admin','action'=>COMPULSORY)); 8 9 $Map->connect('/:controller/:action/:id', array('controller' => 'page', 'action' => 'index'),array('id'=>'\d{1,}')); 9 $Map->connect('/:module/:controller/:action/:id',array('action'=>COMPULSORY));10 10 11 11 ?> branches/kaste/PHPUnit_TestSuite/tests/lib/RoutingTest.php
r918 r924 20 20 function testShouldResolveToAdminModule() 21 21 { 22 $this->get('/admin/user/add /');22 $this->get('/admin/user/add'); 23 23 24 24 $this->assertParameterEquals('admin','module'); … … 29 29 function testRouteToAdminLogs() 30 30 { 31 $this->get('/admin/logs/warnings /show/1');32 $this->assertModule('admin /logs');33 $this->assertController(' warnings');34 $this->assertAction(' show');35 $this->assert Id(1);31 $this->get('/admin/logs/warnings'); 32 $this->assertModule('admin'); 33 $this->assertController('logs'); 34 $this->assertAction('list'); 35 $this->assertParameterEquals('warnings','type'); 36 36 } 37 37
