1
0
Fork 0
mirror of https://github.com/archtechx/tenancy.git synced 2026-02-05 20:34:03 +00:00

Fix ArgumentCount exception on the TenantAssetsController when no $path is provided

This commit is contained in:
Bram Wubs 2022-07-12 12:03:18 +02:00
parent db9480f54e
commit 0db972384a
2 changed files with 21 additions and 4 deletions

View file

@ -15,7 +15,7 @@ class TenantAssetsController extends Controller
$this->middleware(static::$tenancyMiddleware);
}
public function asset($path)
public function asset($path = null)
{
try {
return response()->file(storage_path("app/public/$path"));

View file

@ -34,9 +34,11 @@ class TenantAssetTest extends TestCase
{
parent::setUp();
config(['tenancy.bootstrappers' => [
FilesystemTenancyBootstrapper::class,
]]);
config([
'tenancy.bootstrappers' => [
FilesystemTenancyBootstrapper::class,
]
]);
Event::listen(TenancyInitialized::class, BootstrapTenancy::class);
}
@ -126,4 +128,19 @@ class TenantAssetTest extends TestCase
$this->assertSame($original, asset('foo'));
}
public function test_asset_controller_returns_a_404_when_no_path_is_provided()
{
TenantAssetsController::$tenancyMiddleware = InitializeTenancyByRequestData::class;
$tenant = Tenant::create();
tenancy()->initialize($tenant);
$response = $this->get(tenant_asset(null), [
'X-Tenant' => $tenant->id,
]);
$response->assertNotFound();
}
}