public function testInvoke()
 {
     $params = ['foo' => 'bar', 'bat' => 'baz'];
     $route = new Route('/foo', $params);
     $router = new Router();
     $router->add('foo', $route);
     $server = new Server();
     $request = $server->getRequest();
     $uri = new Uri('/foo');
     $server->setRequest($request->withUri($uri));
     $listener = new RouteMatchListener();
     $listener->setRouter($router);
     $listener->setServer($server);
     $listener(new SystemEvent());
     $request = $server->getRequest();
     $expected = ['foo' => 'bar', 'bat' => 'baz', 'request_method' => 'GET', 'request_scheme' => '', 'route' => 'foo'];
     $this->assertSame($expected, $request->getAttributes());
 }
Example #2
0
 public function testMerge()
 {
     $router = new Router();
     $source = new Router();
     $route = new Route('/foo');
     $source->add('foo', $route);
     $params = ['foo' => 'bar'];
     $source->setDefaultParams($params);
     $router->merge($source);
     $this->assertTrue($router->has('foo'));
     $this->assertSame($route, $router->get('foo'));
     $this->assertSame($params, $router->getDefaultParams());
 }