예제 #1
0
 public function setUp()
 {
     $m = new Horde_Routes_Mapper(array('explicit' => true));
     $m->connect('archive/:year/:month/:day', array('controller' => 'blog', 'action' => 'view', 'month' => null, 'day' => null, 'requirements' => array('month' => '\\d{1,2}', 'day' => '\\d{1,2}')));
     $m->connect('viewpost/:id', array('controller' => 'post', 'action' => 'view', 'id' => null));
     $m->connect(':controller/:action/:id');
     $m->environ = array('SERVER_NAME' => 'www.test.com');
     $this->mapper = $m;
     $this->utils = $m->utils;
 }
예제 #2
0
 public function testScanFilesystem()
 {
     $mapper = new Horde_Routes_Mapper();
     $mapper->connect(':controller/:action/:id');
     $scanner = new Mad_Controller_Scanner($mapper);
     $controllers = $scanner->scanFilesystem(MAD_ROOT . '/app/controllers');
     sort($controllers);
     $this->assertEquals(array('application', 'error', 'unit_test'), $controllers);
 }
예제 #3
0
 public function testOtherSpecialChars()
 {
     $m = new Horde_Routes_Mapper();
     $m->connect('/:year/:(slug).:(format),:(locale)', array('locale' => 'en', 'format' => 'html'));
     $m->createRegs(array('content'));
     $this->assertEquals('/2007/test', $m->generate(array('year' => 2007, 'slug' => 'test')));
     $this->assertEquals('/2007/test.xml', $m->generate(array('year' => 2007, 'slug' => 'test', 'format' => 'xml')));
     $this->assertEquals('/2007/test.xml,ja', $m->generate(array('year' => 2007, 'slug' => 'test', 'format' => 'xml', 'locale' => 'ja')));
     $this->assertNull($m->generate(array('year' => 2007, 'format' => 'html')));
 }
예제 #4
0
 protected function getTestMatchDict($type = 'fetch')
 {
     switch ($type) {
         case 'empty':
             $route = 'trigger/*(folder).pfb';
             $match = array('controller' => 'freebusy', 'action' => 'trigger');
             $path = '/trigger/.pfb';
             break;
         case 'invalid':
             $route = 'trigger/*(folder).pfb';
             $match = array('controller' => 'freebusy', 'action' => 'trigger');
             $path = '/trigger/INVALID.pfb';
             break;
         case 'trigger':
             $route = 'trigger/*(folder).pfb';
             $match = array('controller' => 'freebusy', 'action' => 'trigger');
             $path = '/trigger/owner@example.org/Kalender.pfb';
             break;
         case 'fetch':
         default:
             $route = ':(owner).:(type)';
             $match = array('controller' => 'freebusy', 'action' => 'fetch', 'requirements' => array('type' => '(i|x|v)fb', 'owner' => '[^/]+'));
             $path = '/owner@example.org.xfb';
             break;
     }
     $mapper = new Horde_Routes_Mapper();
     $mapper->connect($route, $match);
     $request = new Horde_Controller_Request_Mock();
     $request->setPath($path);
     return new Horde_Kolab_FreeBusy_Controller_MatchDict($mapper, $request);
 }
예제 #5
0
 public function testMatchDebug()
 {
     $m = new Horde_Routes_Mapper();
     $m->connect('nowhere', 'http://nowhere.com/', array('_static' => true));
     $m->connect(':controller/:action/:id');
     $m->debug = true;
     $m->createRegs(array('content'));
     $route = $m->matchList[1];
     list($resultdict, $resultObj, $debug) = $m->match('/content');
     $this->assertEquals(array('controller' => 'content', 'action' => 'index', 'id' => null), $resultdict);
     $this->assertSame($route, $resultObj);
     list($resultdict, $resultObj, $debug) = $m->match('/nowhere');
     $this->assertNull($resultdict);
     $this->assertNull($resultObj);
     $this->assertEquals(2, count($debug));
 }
예제 #6
0
 public function testAutoControllerScan()
 {
     $hereDir = __DIR__;
     $controllerDir = "{$hereDir}/fixtures/controllers";
     $m = new Horde_Routes_Mapper(array('directory' => $controllerDir));
     $m->alwaysScan = true;
     $m->connect(':controller/:action/:id');
     $expected = array('action' => 'index', 'controller' => 'content', 'id' => null);
     $this->assertEquals($expected, $m->match('/content'));
     $expected = array('action' => 'index', 'controller' => 'users', 'id' => null);
     $this->assertEquals($expected, $m->match('/users'));
     $expected = array('action' => 'index', 'controller' => 'admin/users', 'id' => null);
     $this->assertEquals($expected, $m->match('/admin/users'));
 }