Exemple #1
0
     $gather = gather_info(function () {
         t::get('/:root/*/*/:script.:format', function ($p) {
             printf('rule picked up with %d wildcards, root=%s, script=%s, format=%s', count($p['splats']), $p['root'], $p['script'], $p['format']);
         });
         t::not_found(function () {
             echo 'no rules picked up';
         });
     });
     expect($gather)->to_be('rule picked up with 2 wildcards, root=path, script=download, format=html');
 });
 it("should allow and return mixture of wildcards and named params in a nested call", function () {
     mimick_request('/path/to/file/download.html', 'GET');
     $gather = gather_info(function () {
         t::rel('/:root', function () {
             t::get('/*/*/:script.:format', function ($p) {
                 printf('rule picked up with %d wildcards, root=%s, script=%s, format=%s', count($p['splats']), $p['root'], $p['script'], $p['format']);
             });
         });
         t::not_found(function () {
             echo 'no rules picked up';
         });
     });
     expect($gather)->to_be('rule picked up with 2 wildcards, root=path, script=download, format=html');
 });
 it("should allow commas in paths, relative paths and nested paths", function () {
     mimick_request('/path/to/file/1,2,3', 'GET');
     $gather = gather_info(function () {
         t::get('/path/to/file/*,*,*', function ($p) {
             printf('%d wildcards. %s, %s, %s', count($p['splats']), $p[0], $p[1], $p[2]);
         });
         t::not_found(function () {
Exemple #2
0
                 echo 'get';
             });
         });
         t::not_found(function () {
             echo 'no rules picked up';
         });
     });
     expect($gather)->to_be('get');
     reset_request();
     // mimick get inside of rel()
     mimick_request('/login', 'POST');
     $gather = gather_info(function () {
         t::rel('/login', function () {
             t::get(function () {
                 echo 'get';
             });
             t::post(function () {
                 echo 'post';
             });
         });
         t::not_found(function () {
             echo 'no rules picked up';
         });
     });
     expect($gather)->to_be('post');
 });
 it("should register global functions when requested", function () {
     $gather = gather_info(function () {
         t::register_global_functions();
         if (function_exists('get')) {
             echo 'get()';
         }