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

Rewrite old tests

This commit is contained in:
Samuel Štancl 2020-05-12 23:22:40 +02:00
parent 64383b4c56
commit 89936187ce
71 changed files with 698 additions and 3203 deletions

View file

@ -0,0 +1,46 @@
<?php
declare(strict_types=1);
namespace Stancl\Tenancy\Tests\Features;
use Illuminate\Support\Facades\Route;
use Stancl\Tenancy\Features\CrossDomainRedirect;
use Stancl\Tenancy\Database\Models\Tenant;
use Stancl\Tenancy\Tests\TestCase;
class RedirectTest extends TestCase
{
/** @test */
public function tenant_redirect_macro_replaces_only_the_hostname()
{
config([
'tenancy.features' => [CrossDomainRedirect::class],
]);
Route::get('/foobar', function () {
return 'Foo';
})->name('home');
Route::get('/redirect', function () {
return redirect()->route('home')->domain('abcd');
});
$tenant = Tenant::create();
tenancy()->initialize($tenant);
$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.localhost', 'foo', ['a' => 'as', 'b' => 'df']));
$this->assertSame('http://foo.localhost/abcdef', tenant_route('foo.localhost', 'foo', []));
}
}