Skip to content

Commit

Permalink
Create a separate test
Browse files Browse the repository at this point in the history
  • Loading branch information
imbrish committed May 2, 2018
1 parent c6c1b67 commit a453b7f
Showing 1 changed file with 24 additions and 6 deletions.
30 changes: 24 additions & 6 deletions tests/Routing/RoutingUrlGeneratorTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -59,16 +59,34 @@ public function testBasicGenerationWithFormatting()
$route = new Route(['GET'], '/named-route', ['as' => 'plain']);
$routes->add($route);

$url->formatPathUsing(function ($path, $route) {
if ($route) {
return '/something'.$path.'/'.$route->getName();
}

$url->formatPathUsing(function ($path) {
return '/something'.$path;
});

$this->assertEquals('http://www.foo.com/something/foo/bar', $url->to('foo/bar'));
$this->assertEquals('/something/named-route/plain', $url->route('plain', [], false));
$this->assertEquals('/something/named-route', $url->route('plain', [], false));
}

public function testUrlFormattersShouldReceiveTargetRoute()
{
$url = new UrlGenerator(
$routes = new RouteCollection,
$request = Request::create('http://abc.com/')
);

$namedRoute = new Route(['GET'], '/bar', ['as' => 'plain', 'root' => 'bar.com', 'path' => 'foo']);
$routes->add($namedRoute);

$url->formatHostUsing(function ($root, $route) {
return $route ? 'http://'.$route->getAction('root') : $root;
});

$url->formatPathUsing(function ($path, $route) {
return $route ? '/'.$route->getAction('path') : $path;
});

$this->assertEquals('http://abc.com/foo/bar', $url->to('foo/bar'));
$this->assertEquals('http://bar.com/foo', $url->route('plain'));
}

public function testBasicRouteGeneration()
Expand Down

0 comments on commit a453b7f

Please sign in to comment.