<?php

namespace Tests\Unit;

use App\Models\BlogPost;
use Illuminate\Support\Facades\Storage;
use Tests\TestCase;

class BlogPostBannerUrlTest extends TestCase
{
    public function test_banner_url_uses_public_storage_url_for_blog_paths(): void
    {
        config(['app.url' => 'https://example.test']);

        $post = new BlogPost;
        $post->banner = 'blog/test.jpg';

        $this->assertSame(
            Storage::disk('public')->url('blog/test.jpg'),
            $post->banner_url
        );
    }

    public function test_banner_url_strips_storage_prefix(): void
    {
        config(['app.url' => 'https://example.test']);

        $post = new BlogPost;
        $post->banner = 'storage/blog/test.jpg';

        $this->assertSame(
            Storage::disk('public')->url('blog/test.jpg'),
            $post->banner_url
        );
    }
}
