createTestPost(); $attachment = Attachment::create([ 'board_id' => $this->board->id, 'post_id' => $postId, 'original_filename' => 'thumb.jpg', 'stored_filename' => 'stored-thumb.jpg', 'disk' => 'modules', 'path' => 'attachments/thumb.jpg', 'mime_type' => $mimeType, 'size' => 100, 'collection' => 'attachments', 'order' => 0, ]); $post = Post::with(['thumbnailAttachment', 'board'])->findOrFail($postId); return ['post' => $post, 'attachment' => $attachment]; } /** * @effects board_response_strings_unchanged */ #[Test] public function thumbnail_serializes_preview_url_with_board_slug(): void { ['post' => $post, 'attachment' => $attachment] = $this->createPostWithAttachment('image/jpeg'); $response = (new PostResource($post))->toArray(Request::create('/')); $this->assertSame( '/api/modules/sirsoft-board/boards/'.$this->board->slug.'/attachment/'.$attachment->hash.'/preview', $response['thumbnail'], ); } /** * @effects board_response_strings_unchanged */ #[Test] public function thumbnail_is_null_for_non_image_attachment(): void { ['post' => $post] = $this->createPostWithAttachment('application/pdf'); $response = (new PostResource($post))->toArray(Request::create('/')); $this->assertNull($response['thumbnail']); } }