<?php
/**
 * PhalApi_Mall\Domain\Config_Test
 *
 * 针对 ../src/mall/Domain/Config.php Mall\Domain\Config 类的PHPUnit单元测试
 *
 * @author: dogstar 20200925
 */

namespace tests\Mall\Domain;
use Mall\Domain\Config;

class PhpUnderControl_MallDomainConfig_Test extends \PHPUnit\Framework\TestCase
{
    public $mallDomainConfig;

    protected function setUp()
    {
        parent::setUp();

        $this->mallDomainConfig = new \Mall\Domain\Config();
    }

    protected function tearDown()
    {
        // 输出本次单元测试所执行的SQL语句
        // var_dump(\PhalApi\DI()->tracer->getSqls());

        // 输出本次单元测试所涉及的追踪埋点
        // var_dump(\PhalApi\DI()->tracer->getStack());
    }


    /**
     * @group testGetPayList
     */ 
    public function testGetPayList()
    {
        $checkSwitch = true;

        $rs = $this->mallDomainConfig->getPayList($checkSwitch);

        $this->assertTrue(is_array($rs));
    }

    /**
     * @group testGetDefaultPayType
     */ 
    public function testGetDefaultPayType()
    {
        $rs = $this->mallDomainConfig->getDefaultPayType();

        $this->assertNotEmpty($rs);
    }

    /**
     * @group testGetPayConfigDetail
     */ 
    public function testGetPayConfigDetail()
    {
        $pay_type = 'cash';

        $rs = $this->mallDomainConfig->getPayConfigDetail($pay_type);

        $this->assertNotEmpty($rs);
    }

    /**
     * @group testGetPayConfig
     */ 
    public function testGetPayConfig()
    {
        $rs = $this->mallDomainConfig->getPayConfig();

        $this->assertNotEmpty($rs);
    }

    /**
     * @group testUpdatePayConfig
     */ 
    public function testUpdatePayConfig()
    {
        $config = array('cash' => array('switch' => 0));

        $rs = $this->mallDomainConfig->updatePayConfig($config);

        $rs = $this->mallDomainConfig->getPayConfig();
        // var_dump($rs);

        $this->assertEquals(0, $rs['cash']['switch']);
        $this->assertEquals(1, $rs['alipay']['switch']);
    }

}
