Files
iro2-back-lecture/tests/Feature/FileLinkWebTest.php
2026-02-19 19:47:42 +03:00

39 lines
1.1 KiB
PHP

<?php
namespace Tests\Feature;
use Illuminate\Http\UploadedFile;
use Illuminate\Support\Facades\Config;
use Illuminate\Support\Facades\Storage;
use Tests\TestCase;
class FileLinkWebTest extends TestCase
{
public function test_files_page_shows_disabled_state(): void
{
Config::set('file_links.enabled', false);
$response = $this->get('/files');
$response->assertOk();
$response->assertSee('Функция отключена конфигом');
}
public function test_it_uploads_file_from_web_form_and_returns_temporary_link(): void
{
Storage::fake('local');
Config::set('file_links.enabled', true);
Config::set('file_links.disk', 'local');
Config::set('file_links.directory', 'temporary-links');
$response = $this->post('/files', [
'file' => UploadedFile::fake()->create('web-sample.txt', 1),
]);
$response->assertRedirect('/files');
$response->assertSessionHas('file_link');
$response->assertSessionHas('file_expires_at');
}
}