fix: 修复文档转换与预览链路中的图片、文件名和错误处理问题
This commit is contained in:
@@ -141,6 +141,35 @@ class SwooleQueueCompatibilityTest extends TestCase
|
||||
$job->handle($conversionService);
|
||||
}
|
||||
|
||||
/**
|
||||
* 测试队列任务可以包装底层 Throwable
|
||||
*
|
||||
* @test
|
||||
*/
|
||||
public function test_queue_job_wraps_throwables_from_conversion_service()
|
||||
{
|
||||
$user = User::factory()->create();
|
||||
$document = Document::factory()->create([
|
||||
'uploaded_by' => $user->id,
|
||||
'title' => 'Throwable 测试文档',
|
||||
'file_path' => 'throwable-test.docx',
|
||||
]);
|
||||
|
||||
$conversionService = $this->createMock(DocumentConversionService::class);
|
||||
$conversionService->expects($this->once())
|
||||
->method('convertToMarkdown')
|
||||
->willThrowException(new \Error('底层转换错误'));
|
||||
|
||||
$this->app->instance(DocumentConversionService::class, $conversionService);
|
||||
|
||||
$job = new ConvertDocumentToMarkdown($document);
|
||||
|
||||
$this->expectException(\RuntimeException::class);
|
||||
$this->expectExceptionMessage('底层转换错误');
|
||||
|
||||
$job->handle($conversionService);
|
||||
}
|
||||
|
||||
/**
|
||||
* 测试队列任务的重试机制
|
||||
*
|
||||
@@ -243,4 +272,4 @@ class SwooleQueueCompatibilityTest extends TestCase
|
||||
$jobDocument = $documentProperty->getValue($unserialized);
|
||||
$this->assertEquals($document->id, $jobDocument->id);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user