<?php

/**
 * Created by PhpStorm.
 * User: stanley-king
 * Date: 16/8/14
 * Time: 下午5:29
 */

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

require_once(BASE_ROOT_PATH . '/fooder.php');
require_once(BASE_ROOT_PATH . '/helper/activity_helper.php');
require_once(BASE_ROOT_PATH . '/helper/goods_helper.php');
require_once(BASE_ROOT_PATH . '/helper/message/msgutil.php');


class TestActivity extends PHPUnit_Framework_TestCase
{
    public static function setUpBeforeClass()
    {
        Base::run_util();
    }
    public function testOptionalGoods()
    {
        $instance = activity\optional_goods::instance();
    }

    public function testUrlencode()
    {
        $x = 'http://a.lrlz.com/mobile/api/wxLogin/callback.php';
        $y = urlencode($x);
    }

    public function testGift()
    {
        $time = strftime("%Y-%m-%d %H:%M:%S",1474266342);
        $time = strftime("%Y-%m-%d %H:%M:%S",1474268695);
        $time = strftime("%Y-%m-%d %H:%M:%S",1474268698);
        $helper = new goods_helper();
    }

    public function testBundling()
    {
        $helper = new goods_helper();
    }

    public function testSpu()
    {
        $helper = new goods_helper();
        $ret = $helper->get_spu(2629,4182,$err);
    }

    public function testTesterConfig()
    {
        $config['old_tabs'] = array(
            array('special_id' => 110,'name' => "home3"),
            array('special_id' => 181,'name' => "美妆教学"),
            array('special_id' => 161,'name' => "公司动态"),
            array('special_id' => 184,'name' => "热销榜单"));
        $config['old_specials'] = array(0,23,74,87,105,110,182,184,186,187);
    }

    public function testPublishConfig()
    {
        $config['old_tabs'] = array(
            array('special_id' => 246,'name' => "	推荐"),
            array('special_id' => 190,'name' => "全球专柜"),
            array('special_id' => 220,'name' => "男士"),
            array('special_id' => 197,'name' => "天猫店铺榜"),
            array('special_id' => 211,'name' => "美妆学院"),
            array('special_id' => 195,'name' => "丽人丽妆")
        );
        $config['old_specials'] = array(74,87,105,110,188,190,197,220);
    }

    public function testFull()
    {
        $contents = activity\full_sent::instance()->rules();
        $store_list = Model('store')->getStoreOnlineList(array('store_id' => 6),null,'','store_free_price');
    }
    public function testxActivity()
    {
        $unstart = activity\limitime::instance()->unstart();
    }
    public function testOpgoodsMatch()
    {
        $cart_list = '[{"cart_id":"11575","buyer_id":"39623","store_id":"6","store_name":"\u718a\u732b\u7f8e\u5986","goods_id":"1267","goods_name":"\u59ae\u7ef4\u96c5  \u51dd\u6c34\u6d3b\u91c7\u6ce1\u6cab\u6d01\u9762\u4e73 100g","goods_price":"29.00","goods_num":"1","goods_image":"6_05065322392256869.jpg","bl_id":"0","state":true,"storage_state":true,"goods_commonid":"789","gc_id":"50011977","transport_id":"4","goods_freight":"6.00","goods_vat":"0","goods_storage":"78","goods_storage_alarm":"5","is_fcode":"0","have_gift":"0","groupbuy_info":null,"xianshi_info":null,"goods_spec":"100g","goods_total":"29.00","goods_image_url":"http:\/\/192.168.0.200\/data\/upload\/shop\/store\/goods\/6\/6_05065322392256869_240.jpg"},{"cart_id":"11574","buyer_id":"39623","store_id":"6","store_name":"\u718a\u732b\u7f8e\u5986","goods_id":"1254","goods_name":"\u59ae\u7ef4\u96c5  \u7537\u5973\u6df1\u5c42\u6da6\u80a4\u4e73\u6db2 200ml 200ml","goods_price":"28.00","goods_num":"1","goods_image":"6_05065322249670032.jpg","bl_id":"0","state":true,"storage_state":true,"goods_commonid":"776","gc_id":"121396013","transport_id":"4","goods_freight":"6.00","goods_vat":"0","goods_storage":"5","goods_storage_alarm":"5","is_fcode":"0","have_gift":"0","groupbuy_info":null,"xianshi_info":null,"goods_spec":"200ml","goods_total":"28.00","goods_image_url":"http:\/\/192.168.0.200\/data\/upload\/shop\/store\/goods\/6\/6_05065322249670032_240.jpg"},{"cart_id":"11573","buyer_id":"39623","store_id":"6","store_name":"\u718a\u732b\u7f8e\u5986","goods_id":"1708","goods_name":"\u3010\u65b0\u54c1\u3011\u59ae\u7ef4\u96c5 \u7537\u58eb\u63a7\u6cb9\u52b2\u723d\u4fdd\u6e7f\u9732 50g 50ml","goods_price":"58.00","goods_num":"1","goods_image":"6_05065325234905701.jpg","bl_id":"0","state":true,"storage_state":true,"goods_commonid":"1029","gc_id":"121410035","transport_id":"4","goods_freight":"6.00","goods_vat":"0","goods_storage":"18","goods_storage_alarm":"5","is_fcode":"0","have_gift":"1","groupbuy_info":null,"xianshi_info":null,"goods_spec":"50ml","gift_list":[],"goods_total":"58.00","goods_image_url":"http:\/\/192.168.0.200\/data\/upload\/shop\/store\/goods\/6\/6_05065325234905701_240.jpg"},{"cart_id":"11569","buyer_id":"39623","store_id":"6","store_name":"\u718a\u732b\u7f8e\u5986","goods_id":"3102","goods_name":"\u3010\u65b0\u54c1\u3011\u96ea\u808c\u7cbe \u4f18\u7eaf\u83c1\u534e\u4e73 140ml 140ml","goods_price":"480.00","goods_num":"1","goods_image":"6_05065334053388690.jpg","bl_id":"0","state":true,"storage_state":true,"goods_commonid":"2017","gc_id":"50011980","transport_id":"4","goods_freight":"6.00","goods_vat":"0","goods_storage":"10","goods_storage_alarm":"5","is_fcode":"0","have_gift":"0","groupbuy_info":null,"xianshi_info":null,"goods_spec":"140ml","goods_total":"480.00","goods_image_url":"http:\/\/192.168.0.200\/data\/upload\/shop\/store\/goods\/6\/6_05065334053388690_240.jpg"},{"cart_id":"11567","buyer_id":"39623","store_id":"6","store_name":"\u718a\u732b\u7f8e\u5986","goods_id":"1678","goods_name":"\u3010\u65b0\u54c1\u3011\u76f8\u5b9c\u672c\u8349 \u82af\u51c0\u81ea\u7136\u51c0\u80a4\u4fdd\u6e7f\u6c34 200ml 120g\/ml","goods_price":"79.00","goods_num":"3","goods_image":"6_05219085290323446.jpg","bl_id":"0","state":true,"storage_state":true,"goods_commonid":"1001","gc_id":"50011980","transport_id":"4","goods_freight":"6.00","goods_vat":"0","goods_storage":"60","goods_storage_alarm":"5","is_fcode":"0","have_gift":"0","groupbuy_info":null,"xianshi_info":null,"goods_spec":"120g\/ml","goods_total":"237.00","goods_image_url":"http:\/\/192.168.0.200\/data\/upload\/shop\/store\/goods\/6\/6_05219085290323446_240.jpg"}]';
        $cart_list = json_decode($cart_list,true);

        $matcher = new optional_match($cart_list);
        $op_result = $matcher->match();
        if($op_result != false) {
            $result[6] = $op_result;
        } else {
            $result[6] = array('discount' => 0,'goods_nums' => []);
        }
    }

    public function testGoodsSampler()
    {
        $gids = activity\goods_sampler::instance()->fetch_male(10);
    }
}
