<?php

namespace Kylin\Payment\Tests\Unit;

use Illuminate\Foundation\Testing\TestCase;
use Kylin\Payment\PaymentManager;
use Kylin\Payment\Services\ConfigCacheService;

class PaymentManagerTest extends TestCase
{
    /**
     * 测试支付管理器构造函数
     */
    public function testPaymentManagerConstructor()
    {
        $app = $this->app;
        $configCacheService = new ConfigCacheService($app);
        $manager = new PaymentManager($app, $configCacheService);

        $this->assertInstanceOf(PaymentManager::class, $manager);
    }

    /**
     * 测试创建支付网关实例
     */
    public function testCreateGateway()
    {
        $manager = $this->app->make(PaymentManager::class);

        // 测试创建支付宝网关
        $alipayGateway = $manager->create('alipay');
        $this->assertNotNull($alipayGateway);

        // 测试创建微信支付网关
        $wechatGateway = $manager->create('wechat');
        $this->assertNotNull($wechatGateway);

        // 测试创建银联支付网关
        $unionpayGateway = $manager->create('unionpay');
        $this->assertNotNull($unionpayGateway);

        // 测试创建抖音支付网关
        $douyinGateway = $manager->create('douyin');
        $this->assertNotNull($douyinGateway);

        // 测试创建江苏银行网关
        $jsbankGateway = $manager->create('jsbank');
        $this->assertNotNull($jsbankGateway);

        // 测试创建支付宝国际版网关
        $alipayintlGateway = $manager->create('alipayintl');
        $this->assertNotNull($alipayintlGateway);

        // 测试创建PayPal网关
        $paypalGateway = $manager->create('paypal');
        $this->assertNotNull($paypalGateway);

        // 测试创建Stripe网关
        $stripeGateway = $manager->create('stripe');
        $this->assertNotNull($stripeGateway);

        // 测试创建Google Pay网关
        $googlepayGateway = $manager->create('googlepay');
        $this->assertNotNull($googlepayGateway);

        // 测试创建Apple Pay网关
        $applepayGateway = $manager->create('applepay');
        $this->assertNotNull($applepayGateway);
    }

    /**
     * 测试获取支付网关实例
     */
    public function testGateway()
    {
        $manager = $this->app->make(PaymentManager::class);

        // 测试获取支付宝网关
        $alipayGateway = $manager->gateway('alipay');
        $this->assertNotNull($alipayGateway);

        // 测试获取微信支付网关
        $wechatGateway = $manager->gateway('wechat');
        $this->assertNotNull($wechatGateway);

        // 测试获取默认网关
        $defaultGateway = $manager->gateway();
        $this->assertNotNull($defaultGateway);
    }
}
