<?php

namespace Kylin\Wechat\Tests;

use Kylin\Wechat\Facades\Wechat;

/**
 * Wechat门面测试
 */
class FacadeTest extends TestCase
{
    /**
     * 测试通过门面访问公众号
     */
    public function testFacadeCanAccessOfficialAccount()
    {
        $officialAccount = Wechat::officialAccount();

        $this->assertInstanceOf(\EasyWeChat\OfficialAccount\Application::class, $officialAccount);
    }

    /**
     * 测试通过门面访问小程序
     */
    public function testFacadeCanAccessMiniProgram()
    {
        $miniProgram = Wechat::miniProgram();

        $this->assertInstanceOf(\EasyWeChat\MiniProgram\Application::class, $miniProgram);
    }

    /**
     * 测试通过门面访问指定名称的账号
     */
    public function testFacadeCanAccessWithNamedAccount()
    {
        // 添加测试配置
        $this->app['config']->set('wechat.accounts.official_account.test', [
            'app_id' => 'test_app_id_2',
            'secret' => 'test_secret_2',
            'token' => 'test_token_2',
            'aes_key' => 'test_aes_key_2',
            'response_type' => 'array',
        ]);

        $officialAccount = Wechat::officialAccount('test');

        $this->assertInstanceOf(\EasyWeChat\OfficialAccount\Application::class, $officialAccount);
    }
}