Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
75 changes: 75 additions & 0 deletions tests/Support/SupportUriTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,23 @@

namespace Illuminate\Tests\Support;

use Illuminate\Contracts\Routing\UrlGenerator;
use Illuminate\Support\Uri;
use PHPUnit\Framework\TestCase;

class SupportUriTest extends TestCase
{
public function test_can_build_special_urls()
{
Uri::setUrlGeneratorResolver(fn () => new CustomUrlGeneratorResolver);

$this->assertEquals('https://laravel.com/to', Uri::to('')->value());
$this->assertEquals('https://laravel.com/route', Uri::route('')->value());
$this->assertEquals('https://laravel.com/signed-route', Uri::signedRoute('')->value());
$this->assertEquals('https://laravel.com/signed-route', Uri::temporarySignedRoute('', '')->value());
$this->assertEquals('https://laravel.com/action', Uri::action('')->value());
}

public function test_basic_uri_interactions()
{
$uri = Uri::of($originalUri = 'https://laravel.com/docs/installation');
Expand Down Expand Up @@ -232,3 +244,66 @@ public function test_macroable()
$this->assertSame('https://laravel.com/foobar', (string) $uri->myMacro());
}
}

class CustomUrlGeneratorResolver implements UrlGenerator
{
public function current()
{
return 'https://laravel.com/current';
}

public function previous($fallback = false)
{
// TODO: Implement previous() method.
}

public function to($path, $extra = [], $secure = null)
{
return 'https://laravel.com/to';
}

public function secure($path, $parameters = [])
{
// TODO: Implement secure() method.
}

public function asset($path, $secure = null)
{
// TODO: Implement asset() method.
}

public function route($name, $parameters = [], $absolute = true)
{
return 'https://laravel.com/route';
}

public function signedRoute($name, $parameters = [], $expiration = null, $absolute = true)
{
return 'https://laravel.com/signed-route';
}

public function temporarySignedRoute($name, $expiration, $parameters = [], $absolute = true)
{
return 'https://laravel.com/temporary-signed-route';
}

public function query($path, $query = [], $extra = [], $secure = null)
{
// TODO: Implement query() method.
}

public function action($action, $parameters = [], $absolute = true)
{
return 'https://laravel.com/action';
}

public function getRootControllerNamespace()
{
// TODO: Implement getRootControllerNamespace() method.
}

public function setRootControllerNamespace($rootNamespace)
{
// TODO: Implement setRootControllerNamespace() method.
}
}