39 lines
1.1 KiB
PHP
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');
|
|
}
|
|
}
|
|
|