added it_get_public_user_avatar, it_get_public_system_image test

This commit is contained in:
Peter Papp
2021-03-07 10:07:06 +01:00
parent 5660fcd4dc
commit 6b909c2380
3 changed files with 71 additions and 11 deletions

View File

@@ -0,0 +1,62 @@
<?php
namespace Tests\Feature;
use App\Models\User;
use Illuminate\Foundation\Testing\DatabaseMigrations;
use App\Services\SetupService;
use Illuminate\Http\UploadedFile;
use Laravel\Sanctum\Sanctum;
use Storage;
use Tests\TestCase;
class FileAccessTest extends TestCase
{
use DatabaseMigrations;
public function __construct()
{
parent::__construct();
$this->setup = app()->make(SetupService::class);
}
/**
* @test
*/
public function it_get_public_user_avatar()
{
Storage::fake('local');
$this->setup->create_directories();
$avatar = UploadedFile::fake()
->image('fake-avatar.jpg');
Storage::putFileAs('avatars', $avatar, 'fake-avatar.jpg');
$this->get('avatars/fake-avatar.jpg')
->assertStatus(200);
Storage::assertExists('avatars/fake-avatar.jpg');
}
/**
* @test
*/
public function it_get_public_system_image()
{
Storage::fake('local');
$this->setup->create_directories();
$system = UploadedFile::fake()
->image('fake-logo.jpg');
Storage::putFileAs('system', $system, 'fake-logo.jpg');
$this->get('system/fake-logo.jpg')
->assertStatus(200);
Storage::assertExists('system/fake-logo.jpg');
}
}