mirror of
https://github.com/archtechx/tenancy.git
synced 2025-12-12 17:24:03 +00:00
First TenantAssetTest
This commit is contained in:
parent
22fc843ce3
commit
9ec4fd931a
2 changed files with 13 additions and 3 deletions
|
|
@ -14,7 +14,7 @@ class TenantAssetsController extends Controller
|
||||||
public function asset($path)
|
public function asset($path)
|
||||||
{
|
{
|
||||||
try {
|
try {
|
||||||
return response()->file(storage_path('app/public/' . $path));
|
return response()->file(storage_path("app/public/$path"));
|
||||||
} catch (\Throwable $th) {
|
} catch (\Throwable $th) {
|
||||||
abort(404);
|
abort(404);
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -7,9 +7,19 @@ class TenantAssetTest extends TestCase
|
||||||
/** @test */
|
/** @test */
|
||||||
public function asset_can_be_accessed_using_the_url_returned_by_the_tenant_asset_helper()
|
public function asset_can_be_accessed_using_the_url_returned_by_the_tenant_asset_helper()
|
||||||
{
|
{
|
||||||
$this->markTestIncomplete();
|
|
||||||
$filename = 'testfile' . $this->randomString(10);
|
$filename = 'testfile' . $this->randomString(10);
|
||||||
\Storage::disk('public')->put($filename, 'bar');
|
\Storage::disk('public')->put($filename, 'bar');
|
||||||
$this->get(tenant_asset($filename))->assertSee('bar');
|
$path = storage_path("app/public/$filename");
|
||||||
|
|
||||||
|
// response()->file() returns BinaryFileResponse whose content is
|
||||||
|
// inaccessible via getContent, so ->assertSee() can't be used
|
||||||
|
$this->get(tenant_asset($filename))->assertSuccessful();
|
||||||
|
$this->assertFileExists($path);
|
||||||
|
|
||||||
|
$f = fopen($path, 'r');
|
||||||
|
$content = fread($f, filesize($path));
|
||||||
|
fclose($f);
|
||||||
|
|
||||||
|
$this->assertSame('bar', $content);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue