From 6372ca7397144ed7787df4aec6b4838b3f3f4b8c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Samuel=20=C5=A0tancl?= Date: Wed, 20 Nov 2019 08:22:00 +0100 Subject: [PATCH] Add tests --- ...RedirectMacroTest.php => RedirectTest.php} | 20 ++++++++++++++++++- 1 file changed, 19 insertions(+), 1 deletion(-) rename tests/{Features/TenantRedirectMacroTest.php => RedirectTest.php} (55%) diff --git a/tests/Features/TenantRedirectMacroTest.php b/tests/RedirectTest.php similarity index 55% rename from tests/Features/TenantRedirectMacroTest.php rename to tests/RedirectTest.php index 8ae8cbe5..854fdfc6 100644 --- a/tests/Features/TenantRedirectMacroTest.php +++ b/tests/RedirectTest.php @@ -8,11 +8,16 @@ use Route; use Stancl\Tenancy\Tenant; use Stancl\Tenancy\Tests\TestCase; -class TenantRedirectMacroTest extends TestCase +class RedirectTest extends TestCase { public $autoCreateTenant = false; public $autoInitTenancy = false; + public function setUp(): void + { + parent::setUp(); + } + /** @test */ public function tenant_redirect_macro_replaces_only_the_hostname() { @@ -34,4 +39,17 @@ class TenantRedirectMacroTest extends TestCase $this->get('/redirect') ->assertRedirect('http://abcd/foobar'); } + + /** @test */ + public function tenant_route_helper_generates_correct_url() + { + Route::get('/abcdef/{a?}/{b?}', function () { + return 'Foo'; + })->name('foo'); + + $this->assertSame('http://foo.localhost/abcdef/as/df', tenant_route('foo', ['a' => 'as', 'b' => 'df'], 'foo.localhost')); + $this->assertSame('http://foo.localhost/abcdef', tenant_route('foo', [], 'foo.localhost')); + + $this->assertSame('http://' . request()->getHost() . '/abcdef/x/y', tenant_route('foo', ['a' => 'x', 'b' => 'y'])); + } }