/
githubmirror
/
framework
Обзор
Документация
Войти
/
githubmirror
/
framework
Код
Запросы
0
Пакеты
0
Релизы
0
Аналитика
Безопасность
13.x
tests/Integration/Filesystem/ServeFileTest.php
93 строки
3 KB
Kay W.
Fix path separator encoding in temporaryUrl on local disk (#60230)
22 май 2026, 14:31
Не верифицирован
22 май 2026, 14:31
e974ce6
Код
Авторство
О чём код?
<?php namespace Illuminate\Tests\Integration\Filesystem; use Illuminate\Support\Carbon; use Illuminate\Support\Facades\Storage; use Orchestra\Testbench\Attributes\WithConfig; use Orchestra\Testbench\TestCase; use PHPUnit\Framework\Attributes\RequiresOperatingSystem; #[WithConfig('filesystems.disks.local.serve', true)] class ServeFileTest extends TestCase { protected function setUp(): void { $this->afterApplicationCreated(function () { Storage::put('serve-file-test.txt', 'Hello World'); Storage::put('serve-file-test.txt?pad=x', 'Hello Question'); Storage::put('nested/folder/serve-file-test.txt', 'Hello Nested'); }); $this->beforeApplicationDestroyed(function () { Storage::delete([ 'serve-file-test.txt', 'serve-file-test.txt?pad=x', 'nested/folder/serve-file-test.txt', ]); }); parent::setUp(); } public function testItCanServeAnExistingFile() { $url = Storage::temporaryUrl('serve-file-test.txt', Carbon::now()->addMinute()); $response = $this->get($url); $this->assertSame('Hello World', $response->streamedContent()); } public function testItWill404OnMissingFile() { $url = Storage::temporaryUrl('serve-missing-test.txt', Carbon::now()->addMinute()); $response = $this->get($url); $response->assertNotFound(); } public function testItWill403OnWrongSignature() { $url = Storage::temporaryUrl('serve-file-test.txt', Carbon::now()->addMinute()); $url = $url.'c'; $response = $this->get($url); $response->assertForbidden(); } #[RequiresOperatingSystem('Linux|Darwin')] public function testItCanServeAFileWithUriDelimitersInThePath() { $url = Storage::temporaryUrl('serve-file-test.txt?pad=x', Carbon::now()->addMinute()); $response = $this->get($url); $this->assertSame('Hello Question', $response->streamedContent()); } #[RequiresOperatingSystem('Linux|Darwin')] public function testTemporaryUrlPreservesPathSeparatorsInNestedPaths() { $url = Storage::temporaryUrl('nested/folder/serve-file-test.txt', Carbon::now()->addMinute()); $this->assertStringContainsString('nested/folder/serve-file-test.txt', $url); $response = $this->get($url); $this->assertSame('Hello Nested', $response->streamedContent()); } #[RequiresOperatingSystem('Linux|Darwin')] public function testUriDelimitersInThePathCannotHideAnExpiredUrl() { $url = Storage::temporaryUrl('serve-file-test.txt?pad=x', Carbon::now()->subMinute()); $response = $this->get($url); $response->assertForbidden(); } }