35 lines
1005 B
PHP
35 lines
1005 B
PHP
<?php
|
|
|
|
namespace Tests\Unit;
|
|
|
|
use App\Models\HomeSlide;
|
|
use App\Models\Product;
|
|
use Tests\TestCase;
|
|
|
|
class ImageUrlResolutionTest extends TestCase
|
|
{
|
|
public function test_product_uses_relative_storage_url_for_uploaded_images(): void
|
|
{
|
|
$product = new Product([
|
|
'image_path' => 'products/example.jpg',
|
|
'gallery_paths' => ['products/gallery-1.jpg', 'products/gallery-2.webp'],
|
|
]);
|
|
|
|
$this->assertSame('/storage/products/example.jpg', $product->image_url);
|
|
$this->assertSame([
|
|
'/storage/products/example.jpg',
|
|
'/storage/products/gallery-1.jpg',
|
|
'/storage/products/gallery-2.webp',
|
|
], $product->gallery_urls);
|
|
}
|
|
|
|
public function test_home_slide_uses_relative_storage_url_for_uploaded_images(): void
|
|
{
|
|
$slide = new HomeSlide([
|
|
'image_path' => 'home-slides/banner.webp',
|
|
]);
|
|
|
|
$this->assertSame('/storage/home-slides/banner.webp', $slide->image_url);
|
|
}
|
|
}
|