public function testComplexExternalUrlMapping()
 {
     $routePatten = '/test/local/$testvar/$why/$also';
     $requestUri = '/test/local/bla/whynot/hi';
     $targetUri = 'https://www.google.com/search?q=$testvar&why=$why&also=$also';
     $route = new Route($routePatten, function () {
         // ...
     });
     $request = new Request();
     $request->setRequestUri($requestUri);
     $this->assertTrue($route->matches($request));
     $variableSet = VariableUrl::extractUrlVariables($requestUri, $routePatten);
     $this->assertEquals(['testvar' => 'bla', 'why' => 'whynot', 'also' => 'hi'], $variableSet);
     $mappedOutput = VariableUrl::applyUrlVariables($targetUri, $variableSet);
     $this->assertEquals('https://www.google.com/search?q=bla&why=whynot&also=hi', $mappedOutput);
 }
Beispiel #2
0
 public function testGetSetMatchSubdirectory()
 {
     $route = new Route('/bla.html', null);
     $request = new Request();
     $request->setRequestUri('/my/proj/bla.html');
     $this->assertNull($route->getSubdirectory(), 'Default should be null');
     $this->assertFalse($route->matches($request));
     $this->assertEquals($route, $route->setSubdirectory('/my/proj'), 'Fluent API return');
     $this->assertEquals('/my/proj', $route->getSubdirectory());
     $this->assertTrue($route->matches($request));
     $request->setRequestUri('/bla.html');
     $route->setSubdirectory(null);
     $this->assertTrue($route->matches($request), 'Nullifying subdirectory should disable subdir matching');
 }