1
0
Fork 0
mirror of https://github.com/archtechx/tenancy.git synced 2025-12-12 20:54:04 +00:00

[2.3.0] tenant_route() helper (#229)

* Add tenant_route helper

* Add tests

* Remove redundant setUp()

* Fix test namespaces

* Apply fixes from StyleCI
This commit is contained in:
Samuel Štancl 2019-11-29 00:12:07 +01:00 committed by GitHub
parent 4e477b472f
commit fd00be646e
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
4 changed files with 36 additions and 10 deletions

View file

@ -2,7 +2,7 @@
declare(strict_types=1);
namespace Stancl\Tenancy\Tests\Feature;
namespace Stancl\Tenancy\Tests\Features;
use Stancl\Tenancy\Tests\TestCase;

View file

@ -2,7 +2,7 @@
declare(strict_types=1);
namespace Stancl\Tenancy\Tests\Feature;
namespace Stancl\Tenancy\Tests\Features;
use Stancl\Tenancy\Features\Timestamps;
use Stancl\Tenancy\Tenant;

View file

@ -2,13 +2,12 @@
declare(strict_types=1);
namespace Stancl\Tenancy\Tests\Feature;
namespace Stancl\Tenancy\Tests;
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;
@ -34,4 +33,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']));
}
}