-
Notifications
You must be signed in to change notification settings - Fork 1.3k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Update UrlGenerator to fully extend Illuminates UrlGenerator.
- Loading branch information
Hunter Skrasek
committed
Aug 26, 2016
1 parent
402680c
commit 68eac66
Showing
3 changed files
with
68 additions
and
5 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,46 @@ | ||
<?php namespace Dingo\Api\Tests\Routing; | ||
|
||
use Dingo\Api\Http\Request; | ||
use Dingo\Api\Routing\Route; | ||
use Dingo\Api\Routing\RouteCollection; | ||
use Dingo\Api\Routing\UrlGenerator; | ||
use Dingo\Api\Tests\Stubs\RoutingAdapterStub; | ||
use Illuminate\Container\Container; | ||
use Illuminate\Routing\RouteCollection as IlluminateRouteCollection; | ||
use PHPUnit_Framework_TestCase; | ||
|
||
class UrlGeneratorTest extends PHPUnit_Framework_TestCase | ||
{ | ||
public function setUp() | ||
{ | ||
$this->adapter = new RoutingAdapterStub; | ||
$this->container = new Container; | ||
} | ||
|
||
public function testVersionRouteGeneration() | ||
{ | ||
$url = new UrlGenerator($routes = new IlluminateRouteCollection, $request = Request::create('http://www.foo.com/')); | ||
|
||
$versionedRoutes = new RouteCollection; | ||
$route = new Route( | ||
$this->adapter, $this->container, $request, | ||
new \Illuminate\Routing\Route(['GET',], '/users', ['as' => 'users']) | ||
); | ||
$versionedRoutes->add($route); | ||
$url->setRouteCollections(['v1' => $versionedRoutes]); | ||
|
||
$this->assertSame('/users', $url->version('v1')->route('users', [], false)); | ||
} | ||
|
||
public function testNormalRouteGeneration() | ||
{ | ||
$url = new UrlGenerator($routes = new IlluminateRouteCollection, $request = Request::create('http://www.foo.com/')); | ||
|
||
$route = new \Illuminate\Routing\Route(['GET',], '/users', ['as' => 'users']); | ||
$routes->add($route); | ||
|
||
$url->setRouteCollections(['v1' => new RouteCollection]); | ||
|
||
$this->assertSame('/users', $url->route('users', [], false)); | ||
} | ||
} |