/** * @dataProvider dataRoutesParams */ public function testHandlingWithParams($uri, $pattern, array $exp, array $params) { $route = new Route("some name", $pattern, "some target"); $route->setParameters($params); $result = $route->handle($uri); if (is_array($result)) { unset($result["target"]); } self::assertSame($exp, $result); }
/** * @depends testPatternFunction */ public function testParametersPassing() { $response = new HTTPResponseStorage(); $scope = new Scope(['externalVariable' => 'externalVariableValue']); $route = new Route('/{var1}{var2}/{var3}', 'get', function ($var1, $var2, $var3, $externalVariableValue) { $valueByRef = 18; $this->assertEquals($var1, 2); $this->assertEquals($var2, 'hello'); $this->assertEquals($var3, 'goodbye'); }); $route->pattern('var1', '\\d+'); $request = new HTTPRequestCustom('/2hello/goodbye'); $this->assertTrue($route->handle($request, $response, $scope)); }