mirror of
https://github.com/archtechx/tenancy.git
synced 2026-02-06 00:24:02 +00:00
Convert test cases
This commit is contained in:
parent
405b91085e
commit
a8dcd0dfc9
27 changed files with 3059 additions and 3658 deletions
|
|
@ -2,45 +2,38 @@
|
|||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace Stancl\Tenancy\Tests\Features;
|
||||
|
||||
use Illuminate\Support\Facades\Route;
|
||||
use Stancl\Tenancy\Features\CrossDomainRedirect;
|
||||
use Stancl\Tenancy\Tests\Etc\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],
|
||||
]);
|
||||
uses(TestCase::class);
|
||||
|
||||
Route::get('/foobar', function () {
|
||||
return 'Foo';
|
||||
})->name('home');
|
||||
test('tenant redirect macro replaces only the hostname', function () {
|
||||
config([
|
||||
'tenancy.features' => [CrossDomainRedirect::class],
|
||||
]);
|
||||
|
||||
Route::get('/redirect', function () {
|
||||
return redirect()->route('home')->domain('abcd');
|
||||
});
|
||||
Route::get('/foobar', function () {
|
||||
return 'Foo';
|
||||
})->name('home');
|
||||
|
||||
$tenant = Tenant::create();
|
||||
tenancy()->initialize($tenant);
|
||||
Route::get('/redirect', function () {
|
||||
return redirect()->route('home')->domain('abcd');
|
||||
});
|
||||
|
||||
$this->get('/redirect')
|
||||
->assertRedirect('http://abcd/foobar');
|
||||
}
|
||||
$tenant = Tenant::create();
|
||||
tenancy()->initialize($tenant);
|
||||
|
||||
/** @test */
|
||||
public function tenant_route_helper_generates_correct_url()
|
||||
{
|
||||
Route::get('/abcdef/{a?}/{b?}', function () {
|
||||
return 'Foo';
|
||||
})->name('foo');
|
||||
$this->get('/redirect')
|
||||
->assertRedirect('http://abcd/foobar');
|
||||
});
|
||||
|
||||
$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', []));
|
||||
}
|
||||
}
|
||||
test('tenant route helper generates correct url', function () {
|
||||
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', []));
|
||||
});
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue