<?php

use App\Http\Controllers\Admin\EmailTemplateController;

it('adds src to img when a /storage URL appears shortly after the tag', function () {
    $controller = new EmailTemplateController;

    $input = <<<HTML
    <div>
        <img alt="Logo" width="300" style="display:block;margin:0 auto 16px">
        \n\n
        https://localhost/storage/email-images/logo.png
    </div>
    HTML;

    $ref = new ReflectionClass($controller);
    $method = $ref->getMethod('repairImgWithoutSrc');
    $method->setAccessible(true);

    /** @var string $output */
    $output = $method->invoke($controller, $input);

    expect($output)->toContain('src="https://localhost/storage/email-images/logo.png"');
});
