TestStat.php 4.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138
  1. <?php
  2. /**
  3. * Created by PhpStorm.
  4. * User: stanley-king
  5. * Date: 2017/5/25
  6. * Time: 下午3:55
  7. */
  8. define('BASE_ROOT_PATH',str_replace('/test','',dirname(__FILE__)));
  9. require_once(BASE_ROOT_PATH . '/fooder.php');
  10. require_once(BASE_ROOT_PATH . '/helper/stat_helper.php');
  11. require_once(BASE_ROOT_PATH . '/helper/brand_helper.php');
  12. require_once(BASE_ROOT_PATH . '/helper/category_helper.php');
  13. class TestStat extends PHPUnit_Framework_TestCase
  14. {
  15. public static function setUpBeforeClass()
  16. {
  17. Base::run_util();
  18. }
  19. public function testBonusPaid()
  20. {
  21. $param = ['time' => time(),'use_type' => 2,'rate' => 30,'amount' => 50,'member_id' => 0];
  22. stat_helper::onUseBonus($param);
  23. }
  24. public function testMember()
  25. {
  26. $cur_date = new DateTime();
  27. $cur_date->setDate(2016,8,20);
  28. $inter = new DateInterval('P1D');
  29. $cur_date->sub($inter);
  30. stat_helper::onDaiyMember($cur_date->getTimestamp());
  31. stat_helper::onDaiyBonus($cur_date->getTimestamp());
  32. stat_helper::onDaiyOrder($cur_date->getTimestamp());
  33. }
  34. public function testSelfDiscount()
  35. {
  36. stat_helper::onInitSelfDiscount();
  37. }
  38. public function testInviteeDiscount()
  39. {
  40. stat_helper::onInitInviteesDiscount();
  41. }
  42. public function testDailySelfDicount()
  43. {
  44. $cur_date = new DateTime();
  45. $inter = new DateInterval('P1D');
  46. $cur_date->sub($inter);
  47. stat_helper::onDailySelfDiscount($cur_date->getTimestamp());
  48. }
  49. public function testDailyInviteeDiscount()
  50. {
  51. }
  52. private function inviter($mod_member,$member_id)
  53. {
  54. $members = $mod_member->field('inviter_id')->where(['member_id' => $member_id])->limit(false)->select();
  55. if(empty($members)) {
  56. return false;
  57. }
  58. return intval($members[0]['member_id']);
  59. }
  60. public function testOme()
  61. {
  62. $x = "3.1.7";
  63. $y = intval($x * 100 + 0.5);
  64. }
  65. public function testDecode()
  66. {
  67. $x = 'YWN0PW1lbWJlcl9ib251cyZvcD1pbmRleA%3D%3D';
  68. $y = urldecode($x);
  69. $z = base64_decode($y);
  70. $t = 'special_id=0&act=special&op=index&page=10&curpage=1';
  71. $t1=base64_encode($t);
  72. $t2=urlencode($t1);
  73. $n = 'c3BlY2lhbF9pZD0wJmFjdD1zcGVjaWFsJm9wPWluZGV4JnBhZ2U9MTAmY3VycGFnZT0x';
  74. $k = urlencode($n);
  75. }
  76. public function testBehavior()
  77. {
  78. stat_helper::onDaiyBehavior(strtotime('2018-10-1'));
  79. stat_helper::onDaiyBehavior(strtotime('2018-10-2'));
  80. stat_helper::onDaiyBehavior(strtotime('2018-10-3'));
  81. stat_helper::onDaiyBehavior(strtotime('2018-10-4'));
  82. stat_helper::onDaiyBehavior(strtotime('2018-10-5'));
  83. stat_helper::onDaiyBehavior(strtotime('2018-10-6'));
  84. stat_helper::onDaiyBehavior(strtotime('2018-10-7'));
  85. }
  86. public function testVideo()
  87. {
  88. $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';
  89. $params = preg_split('/&|=/', $squery);
  90. $req = [];
  91. for ($i = 0; $i < count($params); ++$i) {
  92. $key = $params[$i];
  93. $val = $params[++$i];
  94. $req[$key] = urldecode($val);
  95. }
  96. $urls = json_decode($req['third_video'],true);
  97. }
  98. private function onCart($op,$params)
  99. {
  100. return [];
  101. }
  102. public function testClosures()
  103. {
  104. $method_dicts = [];
  105. $method_dicts['login'] = function($op,$params) {
  106. if($op == 'getcodex' || $op == 'getcode') {
  107. $val = $params['mobile'];
  108. return ['type' => 'mobile','data' => $val];
  109. } else {
  110. return [];
  111. }
  112. };
  113. $act = 'login';
  114. $method_dicts[$act]('getcodex',['mobile' => '13911129867']);
  115. $method_dicts['cart'] = [$this,'onCart'];
  116. $method_dicts['cart']('getcodex',['mobile' => '13911129867']);
  117. call_user_func_array($method_dicts['login'],['getcodex',['mobile' => '13911129867']]);
  118. call_user_func_array($method_dicts['cart'], ['getcodex',['mobile' => '13911129867']]);
  119. }
  120. }