Tenant Multi tenancy Laravel Unit Testing issue

  laravel, multi-database, multi-tenant, php

Here is the test case that i created for category testing. I am getting 404 on this route while i have correctly configured the tenant test case and this route is exist on subdomain that was created on chrome browser.

public function test_example()
{
    $response = $this->call('GET', '/categories/6/edit');
    $this->assertEquals(200, $response->getStatusCode(),$response->exception->getMessage());
}

My TestCase.php

  protected $tenancy = false;

public function setUp(): void
{
    parent::setUp();
    if ($this->tenancy) {
        $this->initializeTenancy();
    }
}

public function initializeTenancy()
{
    $tenant = Tenant::create();
    tenancy()->initialize($tenant);
}

Documentation I am following
https://tenancyforlaravel.com/docs/v3/testing

Result:
I want 302 response means redirect to login code.

Source: Laravel

Leave a Reply