Esempio n. 1
0
 /**
  * Route should set name
  */
 public function testRouteSetsName()
 {
     $route = new \Slim\Route('/foo/bar', function () {
     });
     $route->name('foo');
     $this->assertEquals('foo', $route->getName());
 }
Esempio n. 2
0
 /**
  * Test middleware with arguments
  */
 public function testRouteMiddlwareArguments()
 {
     $this->expectOutputString('foobar');
     $route = new \Slim\Route('/foo', function () {
         echo "bar";
     });
     $route->setName('foo');
     $route->setMiddleware(function ($route) {
         echo $route->getName();
     });
     $route->matches('/foo');
     //<-- Extracts params from resource URI
     $route->dispatch();
 }
Esempio n. 3
0
 public function testRouteMiddlwareArguments()
 {
     $this->expectOutputString('foobar');
     \Slim\Environment::mock(array('SCRIPT_NAME' => '', 'PATH_INFO' => '/foo'));
     $env = \Slim\Environment::getInstance();
     $req = new \Slim\Http\Request($env);
     $router = new \Slim\Router();
     $router->setResourceUri($req->getResourceUri());
     $route = new \Slim\Route('/foo', function () {
         echo "bar";
     });
     $route->setName('foo');
     $route->setMiddleware(function ($route) {
         echo $route->getName();
     });
     $route->matches($req->getResourceUri());
     //<-- Extracts params from resource URI
     $router->dispatch($route);
 }