1

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.

Ali Hyder
  • 41
  • 12

1 Answers1

0

I hope this piece of code can help you

https://github.com/archtechx/tenancy/issues/635#issuecomment-939226522

    tenancy()->initialize($tenant);
    URL::forceRootUrl('http://' . $tenant->domains[0]['domain']);
Oxicode
  • 1
  • 1
  • 2