b2in/tests/Feature/ThemeImageUrlTest.php

32 lines
1.2 KiB
PHP

<?php
declare(strict_types=1);
use Illuminate\Foundation\Testing\RefreshDatabase;
uses(RefreshDatabase::class);
test('theme_image_url returns empty string for null or blank', function () {
expect(theme_image_url(null))->toBe('')
->and(theme_image_url(''))->toBe('')
->and(theme_image_url(' '))->toBe('');
});
test('theme_image_url returns legacy path for slash-separated theme paths', function () {
$url = theme_image_url('b2in/example.jpg');
expect($url)->toContain('img/assets/b2in/example.jpg');
});
test('theme_image_url returns public storage path for stored real estate images', function () {
expect(theme_image_url('immobile/dubai/azizi-ruby/overview-thumbnail/example.jpg'))
->toContain('storage/immobile/dubai/azizi-ruby/overview-thumbnail/example.jpg')
->and(theme_image_url('storage/immobile/dubai/azizi-ruby/overview-thumbnail/example.jpg'))
->toContain('storage/immobile/dubai/azizi-ruby/overview-thumbnail/example.jpg');
});
test('theme_image_url passes through absolute http urls', function () {
$url = theme_image_url('https://example.org/x.webp');
expect($url)->toBe('https://example.org/x.webp');
});