<?php

namespace Tests\Tenant;

use App\Facades\Settings;
use App\Http\Resources\SiteResource;
use Tests\TenantTestCase;

class SiteVerificationTest extends TenantTestCase
{
    private function makeVerificationSetting(string $configKey, string $value): void
    {
        Settings::make([
            'tab' => 'Site',
            'section' => 'SEO',
            'group' => 'Site Verification',
            'name' => $configKey,
            'config_key' => $configKey,
            'type' => 'string',
            'value' => $value,
        ]);
    }

    public function testVerificationKeysAreEmptyByDefault(): void
    {
        $resource = new SiteResource([])->toArray(request());

        $this->assertArrayHasKey('google_site_verification', $resource);
        $this->assertArrayHasKey('bing_site_verification', $resource);
        $this->assertEmpty($resource['google_site_verification']);
        $this->assertEmpty($resource['bing_site_verification']);
    }

    public function testVerificationKeysExposeConfiguredValues(): void
    {
        $this->makeVerificationSetting('seo-google-site-verification', 'google-token-123');
        $this->makeVerificationSetting('seo-bing-site-verification', 'bing-token-456');

        $resource = new SiteResource([])->toArray(request());

        $this->assertEquals('google-token-123', $resource['google_site_verification']);
        $this->assertEquals('bing-token-456', $resource['bing_site_verification']);
    }
}
