<?php

/**
 * Created by PhpStorm.
 * User: stanley-king
 * Date: 16/6/27
 * Time: 下午10:27
 */

define('BASE_ROOT_PATH',str_replace('/test','',dirname(__FILE__)));

require_once(BASE_ROOT_PATH . '/fooder.php');
require_once(BASE_ROOT_PATH . '/helper/bonus_helper.php');
require_once(BASE_ROOT_PATH . '/helper/account_helper.php');
require_once(BASE_ROOT_PATH . '/helper/category_helper.php');
require_once(BASE_ROOT_PATH . '/helper/brand_helper.php');

class testAccounthelper extends PHPUnit_Framework_TestCase
{
    public static function setUpBeforeClass()
    {
        Base::run_util();
    }
    public function testInviteBonus()
    {
        account_helper::invite_bonus(36490);
    }
    public function testEvaluate()
    {
        account_helper::onAsyncOrderEvaluate();
    }
    public function testGainSystem()
    {
        account_helper::gain_system(36490,4.5);
    }
    public function testGainBonus()
    {
        account_helper::gain_bonus(36490,36485,4.5);
    }
    public function testLostBonus()
    {
        account_helper::gain_bonus(36490,36485,4.5);
    }
    public function testOnRegister()
    {
        account_helper::onRegister(36490,session_helper::relay_id());
    }

    public function testOrderCancel()
    {
        account_helper::order_cancel('8000000000001603',36490);
    }
    public function testPayRefund()
    {
        //account_helper::pay_refund(36490,500,'退款红包');
    }
    public function testPaysuccess()
    {
        $pay_sn = '910510761110261481';
        account_helper::onAsyncOrderPaied($pay_sn);
    }
    public function testOrderSuccessSys()
    {
        $mod = Model('order');
        $pay_sn = '910510761110261481';
        $order_info = $mod->getOrderInfo(array('pay_sn' => $pay_sn));
        $logic_order = Logic('order');
        $result = $logic_order->changeOrderStateReceive($order_info,'system','系统','超期未收货系统自动完成订单');
    }

    public function testUpfile()
    {
        $file = '/Users/stanley-king/work/PHPProject/shopnc/data/upload/uploadtmp/20161215081131-53be4be9-fe01-50e7-28c0-ded900c9a0f6.jpg';
        $ext = exif_imagetype($file);
        $exif = image_type_to_mime_type($ext);
        $tagnmae = exif_tagname($ext);

        $info = new SplFileInfo($file);
        $type = $info->getType();
        $type = $info->getExtension();
        $size = $info->getSize();
        $tmp_name = $info->getFilename();
    }

    public function testTask()
    {
        account_helper::onAsyncBroadcastOrder('290563492188164623',0.1,30);
    }

    public static function tearDownAfterClass()
    {
    }

}
