123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138 |
- <?php
- /**
- * Created by PhpStorm.
- * User: stanley-king
- * Date: 2017/5/25
- * Time: 下午3:55
- */
- define('BASE_ROOT_PATH',str_replace('/test','',dirname(__FILE__)));
- require_once(BASE_ROOT_PATH . '/fooder.php');
- require_once(BASE_ROOT_PATH . '/helper/stat_helper.php');
- require_once(BASE_ROOT_PATH . '/helper/brand_helper.php');
- require_once(BASE_ROOT_PATH . '/helper/category_helper.php');
- class TestStat extends PHPUnit_Framework_TestCase
- {
- public static function setUpBeforeClass()
- {
- Base::run_util();
- }
- public function testBonusPaid()
- {
- $param = ['time' => time(),'use_type' => 2,'rate' => 30,'amount' => 50,'member_id' => 0];
- stat_helper::onUseBonus($param);
- }
- public function testMember()
- {
- $cur_date = new DateTime();
- $cur_date->setDate(2016,8,20);
- $inter = new DateInterval('P1D');
- $cur_date->sub($inter);
- stat_helper::onDaiyMember($cur_date->getTimestamp());
- stat_helper::onDaiyBonus($cur_date->getTimestamp());
- stat_helper::onDaiyOrder($cur_date->getTimestamp());
- }
- public function testSelfDiscount()
- {
- stat_helper::onInitSelfDiscount();
- }
- public function testInviteeDiscount()
- {
- stat_helper::onInitInviteesDiscount();
- }
- public function testDailySelfDicount()
- {
- $cur_date = new DateTime();
- $inter = new DateInterval('P1D');
- $cur_date->sub($inter);
- stat_helper::onDailySelfDiscount($cur_date->getTimestamp());
- }
- public function testDailyInviteeDiscount()
- {
- }
- private function inviter($mod_member,$member_id)
- {
- $members = $mod_member->field('inviter_id')->where(['member_id' => $member_id])->limit(false)->select();
- if(empty($members)) {
- return false;
- }
- return intval($members[0]['member_id']);
- }
- public function testOme()
- {
- $x = "3.1.7";
- $y = intval($x * 100 + 0.5);
- }
- public function testDecode()
- {
- $x = 'YWN0PW1lbWJlcl9ib251cyZvcD1pbmRleA%3D%3D';
- $y = urldecode($x);
- $z = base64_decode($y);
- $t = 'special_id=0&act=special&op=index&page=10&curpage=1';
- $t1=base64_encode($t);
- $t2=urlencode($t1);
- $n = 'c3BlY2lhbF9pZD0wJmFjdD1zcGVjaWFsJm9wPWluZGV4JnBhZ2U9MTAmY3VycGFnZT0x';
- $k = urlencode($n);
- }
- public function testBehavior()
- {
- stat_helper::onDaiyBehavior(strtotime('2018-10-1'));
- stat_helper::onDaiyBehavior(strtotime('2018-10-2'));
- stat_helper::onDaiyBehavior(strtotime('2018-10-3'));
- stat_helper::onDaiyBehavior(strtotime('2018-10-4'));
- stat_helper::onDaiyBehavior(strtotime('2018-10-5'));
- stat_helper::onDaiyBehavior(strtotime('2018-10-6'));
- stat_helper::onDaiyBehavior(strtotime('2018-10-7'));
- }
- public function testVideo()
- {
- $squery = 'auto_play=0&version=1&refer=pc-shop.xiaoe-tech.com&jscbid=video_1537980066935&disable_full_screen=0&definition=230&third_video=%7B%22urls%22%3A%7B%22230%22%3A%22http%3A%2F%2Fvod2.xiaoe-tech.com%2F9764a7a5vodtransgzp1252524126%2F1fc69fca5285890780828061224%2Fdrm%2Fv.f230.m3u8%3Ft%3D5babb9f9%26us%3D285035%26sign%3D1ec34ce976e1c042c8f3363a97daae90%22%7D%7D';
- $params = preg_split('/&|=/', $squery);
- $req = [];
- for ($i = 0; $i < count($params); ++$i) {
- $key = $params[$i];
- $val = $params[++$i];
- $req[$key] = urldecode($val);
- }
- $urls = json_decode($req['third_video'],true);
- }
- private function onCart($op,$params)
- {
- return [];
- }
- public function testClosures()
- {
- $method_dicts = [];
- $method_dicts['login'] = function($op,$params) {
- if($op == 'getcodex' || $op == 'getcode') {
- $val = $params['mobile'];
- return ['type' => 'mobile','data' => $val];
- } else {
- return [];
- }
- };
- $act = 'login';
- $method_dicts[$act]('getcodex',['mobile' => '13911129867']);
- $method_dicts['cart'] = [$this,'onCart'];
- $method_dicts['cart']('getcodex',['mobile' => '13911129867']);
- call_user_func_array($method_dicts['login'],['getcodex',['mobile' => '13911129867']]);
- call_user_func_array($method_dicts['cart'], ['getcodex',['mobile' => '13911129867']]);
- }
- }
|