This commit is contained in:
16
tests/Unit/ExampleTest.php
Normal file
16
tests/Unit/ExampleTest.php
Normal file
@@ -0,0 +1,16 @@
|
||||
<?php
|
||||
|
||||
namespace Tests\Unit;
|
||||
|
||||
use PHPUnit\Framework\TestCase;
|
||||
|
||||
class ExampleTest extends TestCase
|
||||
{
|
||||
/**
|
||||
* A basic test example.
|
||||
*/
|
||||
public function test_that_true_is_true(): void
|
||||
{
|
||||
$this->assertTrue(true);
|
||||
}
|
||||
}
|
||||
34
tests/Unit/ImageUrlResolutionTest.php
Normal file
34
tests/Unit/ImageUrlResolutionTest.php
Normal file
@@ -0,0 +1,34 @@
|
||||
<?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);
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user