Files
shopit-back/tests/Feature/Tenant/TenantBootstrapRouteTest.php

41 lines
1.4 KiB
PHP

<?php
namespace Tests\Feature\Tenant;
use App\Domains\Core\Bootstrap\Controllers\TenantBootstrapController;
use Illuminate\Http\Request;
use Symfony\Component\HttpKernel\Exception\MethodNotAllowedHttpException;
use Tests\TestCase;
class TenantBootstrapRouteTest extends TestCase
{
public function test_the_static_bootstrap_route_takes_precedence_over_the_tenant_resource(): void
{
$route = app('router')->getRoutes()->match(
Request::create('/api/tenants/bootstrap', 'GET')
);
$this->assertSame(TenantBootstrapController::class, $route->getActionName());
}
public function test_tenant_creation_and_update_routes_are_not_available(): void
{
$routes = app('router')->getRoutes();
$this->assertNull($routes->getByName('tenants.store'));
$this->assertNull($routes->getByName('tenants.update'));
foreach ([['POST', '/api/tenants'], ['PUT', '/api/tenants/demo'], ['PATCH', '/api/tenants/demo']] as [$method, $uri]) {
try {
$routes->match(Request::create($uri, $method));
$this->fail("Unexpected route: {$method} {$uri}");
} catch (MethodNotAllowedHttpException $exception) {
$this->assertSame(405, $exception->getStatusCode());
}
}
foreach (['tenants.index', 'tenants.show', 'tenants.destroy'] as $name) {
$this->assertNotNull($routes->getByName($name));
}
}
}