mirror of
https://github.com/archtechx/tenancy.git
synced 2025-12-12 22:14:03 +00:00
Identification middleware & tests
This commit is contained in:
parent
a17727b437
commit
8ea4940f34
18 changed files with 362 additions and 174 deletions
|
|
@ -10,13 +10,6 @@ use Stancl\Tenancy\Tests\TestCase;
|
|||
|
||||
class PathIdentificationTest extends TestCase
|
||||
{
|
||||
public function getEnvironmentSetup($app)
|
||||
{
|
||||
parent::getEnvironmentSetUp($app);
|
||||
|
||||
config(['tenancy.global_middleware' => []]);
|
||||
}
|
||||
|
||||
public function setUp(): void
|
||||
{
|
||||
parent::setUp();
|
||||
|
|
@ -28,8 +21,6 @@ class PathIdentificationTest extends TestCase
|
|||
Route::get('/foo/{a}/{b}', function ($a, $b) {
|
||||
return "$a + $b";
|
||||
});
|
||||
|
||||
Route::get('/bar', [TestController::class, 'index']);
|
||||
});
|
||||
}
|
||||
|
||||
|
|
@ -42,8 +33,7 @@ class PathIdentificationTest extends TestCase
|
|||
|
||||
$this->assertFalse(tenancy()->initialized);
|
||||
|
||||
$this
|
||||
->get('/acme/foo/abc/xyz');
|
||||
$this->get('/acme/foo/abc/xyz');
|
||||
|
||||
$this->assertTrue(tenancy()->initialized);
|
||||
$this->assertSame('acme', tenant('id'));
|
||||
|
|
@ -77,4 +67,16 @@ class PathIdentificationTest extends TestCase
|
|||
|
||||
$this->assertFalse(tenancy()->initialized);
|
||||
}
|
||||
|
||||
/** @test */
|
||||
public function onfail_logic_can_be_customized()
|
||||
{
|
||||
InitializeTenancyByPath::$onFail = function () {
|
||||
return 'foo';
|
||||
};
|
||||
|
||||
$this
|
||||
->get('/acme/foo/abc/xyz')
|
||||
->assertSee('foo');
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue