<?php

/**
 * Created by PhpStorm.
 * User: stanley-king
 * Date: 2017/4/11
 * Time: 下午5:52
 */

define('BASE_ROOT_PATH',str_replace('/test','',dirname(__FILE__)));
require_once(BASE_ROOT_PATH . '/fooder.php');
require_once(BASE_ROOT_PATH . '/helper/memsg/message_sender.php');
require_once(BASE_ROOT_PATH . '/helper/push_sender.php');

class TestPush extends PHPUnit_Framework_TestCase
{
    const test_android_member_id = 39625;//40287; //android
    const test_ios_member_id = 39623;//52169;
    //const test_member_id = 36490;

    public static function setUpBeforeClass()
    {
        Base::run_util();
    }

    public function testPusher()
    {
        $sender = new memsg\message_sender();
        $sender->send();
    }

    public function testTenPaysuccess()
    {
        for ($i = 0; $i < 10; ++$i)
        {
            push_helper::paysuccess_bonus(self::test_android_member_id,100);
            push_helper::paysuccess_bonus(self::test_ios_member_id,100);
        }
    }

    public function testPaysuccess()
    {
        account_helper::onAsyncOrderPaied('270563196360813623');
    }
    public function testOrderComplete()
    {
        account_helper::onAsyncOrderComplete('270563196360813623');
    }

    public function testMessage()
    {
        $pushor = new push_sender();

        $info['member_id'] = self::test_member_id;
        $info['text'] = 'hello message';
        $info['custom'] = ['type' => 'add_special','special_id' => 300];
        $pushor->send_message($info);
    }

    public function testDialog()
    {
        $fc_id = 3070;
        $mod_fcode = Model('goods_fcode');
        $fcode = $mod_fcode->getGoodsFCode(['fc_id' => $fc_id],true);

        push_helper::first_present(self::test_android_member_id,$fcode);
        push_helper::first_present(self::test_ios_member_id,$fcode);
    }
    public function testAsyncPush()
    {
        QueueClient::async_push('onAsyncRegister',['user' => self::test_ios_member_id,'inviter' => self::test_android_member_id],1);
    }
    public function testBroadcast()
    {
        //"http://t.cn/RYTpzAr"
        $send_params =['type' => Sms::tpl_new_goods,
            'sms_params'  => ['day' => '周一','amount' => 50,'brand' => "婵真",'url' => "http://t.cn/RYTpzAr"],
            'push_params' => []];

        $filters = ['member_filters' => [ ['type' => 'bonus','amount' => 50000],['type' => 'mobile']],
            'sms_filters' => [['type' => 'regtime','days' => 5]]];

        $oper_param = ['type' => 'bonus','rate' => 30,'amount' => 50];

        account_helper::onAsyncBroadcastNormal($filters,$oper_param,$send_params);
    }

    public function testStaticCall()
    {
        
    }
}
