38 lines
1.0 KiB
PHP
38 lines
1.0 KiB
PHP
<?php
|
|||
|
|
|
||
|
|
namespace Tests\Unit;
|
||
|
|
|
||
|
|
use App\Models\File;
|
||
|
|
use Illuminate\Support\Facades\Config;
|
||
|
|
use Tests\TestCase;
|
||
|
|
|
||
|
|
class FilePublicUrlTest extends TestCase
|
||
|
|
{
|
||
|
|
public function test_public_url_uses_config_domain_with_storage_path(): void
|
||
|
|
{
|
||
|
|
Config::set('app.domain', 'https://garoosigholaktala.ir/server');
|
||
|
|
|
||
|
|
$url = File::publicUrl('storage/1405/02/27/sample.jpg');
|
||
|
|
|
||
|
|
$this->assertSame(
|
||
|
|
'https://garoosigholaktala.ir/server/storage/1405/02/27/sample.jpg',
|
||
|
|
$url
|
||
|
|
);
|
||
|
|
}
|
||
|
|
|
||
|
|
public function test_public_url_derives_server_base_from_admin_url_setting(): void
|
||
|
|
{
|
||
|
|
Config::set('app.domain', null);
|
||
|
|
Config::set('app.url', 'http://localhost');
|
||
|
|
|
||
|
|
\App\Models\Setting::query()->updateOrCreate(
|
||
|
|
['key' => 'admin_url'],
|
||
|
|
['value' => 'https://garoosigholaktala.ir/admin/', 'is_active' => 1, 'title_fa' => 'admin']
|
||
|
|
);
|
||
|
|
|
||
|
|
$base = File::resolvePublicBaseUrl();
|
||
|
|
|
||
|
|
$this->assertSame('https://garoosigholaktala.ir/server', $base);
|
||
|
|
}
|
||
|
|
}
|