<?php

namespace Tests;

use Illuminate\Foundation\Testing\RefreshDatabase;
use Illuminate\Foundation\Testing\TestCase as BaseTestCase;
use Tests\Concerns\LoadsApplicationData;

abstract class TestCase extends BaseTestCase
{
    use LoadsApplicationData;
    use RefreshDatabase;

    /**
     * Setup the test environment.
     */
    protected function setUp(): void
    {
        parent::setUp();

        // Set up common test configurations
        config(['app.settings.configuration_settings' => json_encode([
            'enable_create_from_url' => true,
            'disable_mailbox_slug' => false,
            'domains' => ['gmail.com', 'outlook.com', 'example.com'],
            'add_mail_in_title' => false,
            'fetch_seconds' => 30,
        ])]);

        config(['app.settings.ads_settings' => json_encode([
            'enabled' => false,
            'provider' => 'google',
            'one' => '<!-- Ad content placeholder -->',
            'two' => '<!-- Ad content placeholder -->',
        ])]);

        config(['app.settings.app_meta' => json_encode([
            'author' => 'Test Author',
            'keywords' => 'test,keywords',
        ])]);

        config(['app.settings.app_name' => 'Test App']);
        config(['app.settings.app_title' => 'Test App Title']);
        config(['app.settings.app_description' => 'Test App Description']);
        config(['app.settings.app_header' => '']);
        config(['app.settings.app_footer' => '']);
        config(['app.menus' => []]);

        config(['app.beta_feature' => false]);
        config(['app.force_db_mail' => false]);
        config(['app.fetch_from_db' => false]);
        config(['app.locales' => ['en', 'es', 'fr', 'de']]);

        // Set up plans configuration for Dashboard tests
        config(['app.plans' => [
            [
                'name' => 'Basic Plan',
                'product_id' => 'prod_basic123',
                'pricing_id' => 'price_basic123',
                'accept_stripe' => true,
            ],
            [
                'name' => 'Premium Plan',
                'product_id' => 'prod_premium456',
                'pricing_id' => 'price_premium456',
                'accept_stripe' => true,
            ],
        ]]);

        // Load application data for tests that need it
        $this->loadApplicationData();
    }
}
