Example #1
0
         expect($new_route->pathToRegEx())->toBe('`^uri/(?<param>[A-Za-z0-9._-]+)$`');
     });
     it('should interpret a simple path with complex parameter', function () {
         $new_route = new Route('name_path', 'uri/{id}', 'action@controleur');
         $new_route->setRules(["id" => "[0-9]+"]);
         expect($new_route->pathToRegEx())->toBe('`^uri/(?<id>[0-9]+)$`');
     });
     it('should interpret a complex path with complex parameter', function () {
         $new_route = new Route('name_path', 'uri/{id}/action/{hexa}', 'action@controleur');
         $new_route->setRules(["id" => "[0-9]+", "hexa" => "[0-9a-fA-F]{2}"]);
         expect($new_route->pathToRegEx())->toBe('`^uri/(?<id>[0-9]+)/action/(?<hexa>[0-9a-fA-F]{2})$`');
     });
     it('should interpret a simple path with complex parameter with capturing group', function () {
         $new_route = new Route('name_path', 'uri/{slug}', 'action@controleur');
         $new_route->setRules(["slug" => "(A[b-z]+)|(B[ac-z]+)"]);
         expect($new_route->pathToRegEx())->toBe('`^uri/(?<slug>(?:A[b-z]+)|(?:B[ac-z]+))$`');
     });
 });
 describe('Execution', function () {
     it('should execut an route with action/controler action', function () {
         class foo
         {
             public function bar()
             {
                 echo 'bar@foo ok';
             }
             public function bad()
             {
                 echo 'bad@foo ko';
             }
         }