feat(fixtures): committed test photo.png + doc.pdf, helper prefers storage/uploads override
All checks were successful
Deploy Max Bot Test / deploy (push) Successful in 12s
All checks were successful
Deploy Max Bot Test / deploy (push) Successful in 12s
Commands /upload_photo_file, /upload_file now resolve from fixtures/ by default. Drop your own files in storage/uploads/ to override without touching git. audio.mp3 and video.mp4 still need to be added manually (no ffmpeg locally to generate). Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
This commit is contained in:
14
fixtures/doc.pdf
Normal file
14
fixtures/doc.pdf
Normal file
@@ -0,0 +1,14 @@
|
|||||||
|
%PDF-1.4
|
||||||
|
1 0 obj<</Type/Catalog/Pages 2 0 R>>endobj
|
||||||
|
2 0 obj<</Type/Pages/Kids[3 0 R]/Count 1>>endobj
|
||||||
|
3 0 obj<</Type/Page/MediaBox[0 0 200 200]/Parent 2 0 R/Resources<<>>>>endobj
|
||||||
|
xref
|
||||||
|
0 4
|
||||||
|
0000000000 65535 f
|
||||||
|
0000000009 00000 n
|
||||||
|
0000000054 00000 n
|
||||||
|
0000000099 00000 n
|
||||||
|
trailer<</Size 4/Root 1 0 R>>
|
||||||
|
startxref
|
||||||
|
168
|
||||||
|
%%EOF
|
||||||
BIN
fixtures/photo.png
Normal file
BIN
fixtures/photo.png
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 68 B |
@@ -17,6 +17,18 @@ final class UploadsScenario extends AbstractScenario
|
|||||||
private const DEFAULT_PHOTO_URL = 'https://placehold.co/600x400/png';
|
private const DEFAULT_PHOTO_URL = 'https://placehold.co/600x400/png';
|
||||||
private const DEFAULT_FILE_URL = 'https://www.w3.org/WAI/ER/tests/xhtml/testfiles/resources/pdf/dummy.pdf';
|
private const DEFAULT_FILE_URL = 'https://www.w3.org/WAI/ER/tests/xhtml/testfiles/resources/pdf/dummy.pdf';
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Look for a fixture in storage/uploads/ (override, gitignored) first, fall back to fixtures/ (committed).
|
||||||
|
*/
|
||||||
|
private static function fixturePath(string $filename): string
|
||||||
|
{
|
||||||
|
$override = __DIR__ . '/../../storage/uploads/' . $filename;
|
||||||
|
if (is_file($override)) {
|
||||||
|
return $override;
|
||||||
|
}
|
||||||
|
return __DIR__ . '/../../fixtures/' . $filename;
|
||||||
|
}
|
||||||
|
|
||||||
public function handle(MessageCreatedUpdate $update, ParsedCommand $command): void
|
public function handle(MessageCreatedUpdate $update, ParsedCommand $command): void
|
||||||
{
|
{
|
||||||
switch ($command->name) {
|
switch ($command->name) {
|
||||||
@@ -49,9 +61,9 @@ final class UploadsScenario extends AbstractScenario
|
|||||||
|
|
||||||
private function uploadPhotoFromFile(MessageCreatedUpdate $update, ParsedCommand $command): void
|
private function uploadPhotoFromFile(MessageCreatedUpdate $update, ParsedCommand $command): void
|
||||||
{
|
{
|
||||||
$path = $command->arg(0, __DIR__ . '/../../storage/uploads/photo.png');
|
$path = $command->arg(0, self::fixturePath('photo.png'));
|
||||||
if (!is_file($path)) {
|
if (!is_file($path)) {
|
||||||
$this->replyMarkdown($update, "File not found: `$path`. Положи PNG в storage/uploads/photo.png.");
|
$this->replyMarkdown($update, "File not found: `$path`. Положи PNG в fixtures/photo.png или storage/uploads/photo.png.");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
$tokens = $this->api->uploads->uploadPhotoFromFile($path);
|
$tokens = $this->api->uploads->uploadPhotoFromFile($path);
|
||||||
@@ -85,15 +97,15 @@ final class UploadsScenario extends AbstractScenario
|
|||||||
|
|
||||||
private function uploadMediaFromFile(MessageCreatedUpdate $update, ParsedCommand $command, UploadType $type): void
|
private function uploadMediaFromFile(MessageCreatedUpdate $update, ParsedCommand $command, UploadType $type): void
|
||||||
{
|
{
|
||||||
$default = __DIR__ . '/../../storage/uploads/' . match ($type) {
|
$filename = match ($type) {
|
||||||
UploadType::Audio => 'audio.mp3',
|
UploadType::Audio => 'audio.mp3',
|
||||||
UploadType::Video => 'video.mp4',
|
UploadType::Video => 'video.mp4',
|
||||||
UploadType::File => 'doc.pdf',
|
UploadType::File => 'doc.pdf',
|
||||||
UploadType::Photo => 'photo.png',
|
UploadType::Photo => 'photo.png',
|
||||||
};
|
};
|
||||||
$path = $command->arg(0, $default);
|
$path = $command->arg(0, self::fixturePath($filename));
|
||||||
if (!is_file($path)) {
|
if (!is_file($path)) {
|
||||||
$this->replyMarkdown($update, "File not found: `$path`. Положи файл в storage/uploads/.");
|
$this->replyMarkdown($update, "File not found: `$path`. Положи файл в fixtures/ или storage/uploads/.");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
$info = $this->api->uploads->uploadMediaFromFile($type, $path);
|
$info = $this->api->uploads->uploadMediaFromFile($type, $path);
|
||||||
|
|||||||
Reference in New Issue
Block a user