123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192 |
- <?php
- /**
- * Created by PhpStorm.
- * User: stanley-king
- * Date: 16/6/21
- * Time: 下午8:28
- */
- 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/bonus/witholder.php');
- require_once(BASE_ROOT_PATH . '/helper/bonus/norate_holder.php');
- require_once(BASE_ROOT_PATH . '/helper/notify_helper.php');
- require_once(BASE_ROOT_PATH . '/data/mobile/lrlz_staff.php');
- class TestBonus extends PHPUnit_Framework_TestCase
- {
- public static function setUpBeforeClass()
- {
- Base::run_util();
- }
- public static function tearDownAfterClass()
- {
- }
- public function testSend()
- {
- $param = bonus\parameters::test_bonus();
- $ret = bonus_helper::make_bonus($param, $param['rate_money']);
- if ($ret != false) {
- $type_sn = $ret['type_sn'];
- $bonus = bonus_helper::send($type_sn, [39659]);
- return $type_sn;
- } else {
- return false;
- }
- }
- public function testScaler()
- {
- //$scaler = new \bonus\scaler([10 => 10,100 => 100,50 => 50, 30 => 30]);
- //$scaler = new \bonus\scaler([10 => 10,50 => 50, 20 => 60,100 => 100]);
- $scaler = new \bonus\scaler([30 => 0.62, 100 => 1.26]);
- $ret = $scaler->calc();
- }
- public function testModel()
- {
- $item = Model('user_bonus')->field('*')->where(array('type_id' => 105, 'bonus_id' => 2491))->select();
- bonus_helper::shake($item[0]['type_id'], $item[0]['bonus_id'], $item[0]['bonus_value'], 3, bonus_helper::direct_dec());
- }
- public function testMemBonus()
- {
- $x = false;
- if ($x) {
- $user_bonus = 0;
- }
- $bonus_val = $user_bonus->bonus_value();
- $mem_bonus = new \bonus\witholder(36490);
- $mem_bonus->withold(7.30);
- }
- public function testExpire()
- {
- notify_helper::bonus_expired();
- }
- public function testPush()
- {
- $url = 'http://a.lrlz.com/mobile/index.php?act=rank_list&op=index&client_type=wap&list_sn=%3Cddc6ff0cd400941d3ae0f8b0889d54a1%3E&from=timeline&isappinstalled=0';
- $url = urldecode($url);
- }
- public function testTime()
- {
- $send_date = new DateTime();
- $send_date->setTimestamp(1478313092);
- $usable_date = new DateTime();
- $usable_date->setTimestamp(1480905244);
- }
- public function testKeysort()
- {
- $x = RESOURCE_SITE_URL;
- $data = array(10 => 3018.25, 90 => 5623, 30 => 5566);
- ksort($data);
- $xdata = $data;
- krsort($data);
- //arsort($data);
- // $xxxx = array_reverse($xdata,true);
- $xxxx = [];
- foreach ($data as $key => $val) {
- $xxxx[$key] = $val;
- }
- }
- public function testRegex()
- {
- $src = '30|1980|165#60|10|20#50|10|5';
- $params = explode('#', urldecode($src));
- $result = [];
- foreach ($params as $val) {
- if (preg_match_all('/^(\d{1,2})\|(\d{1,4})\|(\d{1,6})$/', $val, $match)) {
- $item['rate'] = intval($match[1]);
- $item['amount'] = intval($match[2]);
- $item['num'] = intval($match[3]);
- $result[] = $item;
- }
- }
- //$regxp = '/([0-9^|#]*|[0-9^|#]*|[0-9^|#]*)[#]?/i';
- // $regxp = '/(([0-9]*){3}[#]?/i';
- $regxp = '/(([0-9]*)|([0-9]*)|([0-9]*)[^#]){1}[#]?/i';
- $val = preg_match_all($regxp, $src, $match);
- }
- public function testMicro()
- {
- microtime();
- }
- public function testRefundBonus()
- {
- account_helper::bonus_refund('700532450973112490', 36490);
- }
- public function testBonusShare()
- {
- $mod_share = Model('bonus_share');
- $items = $mod_share->getAll();
- }
- private function make_sn()
- {
- return mt_rand(10, 99)
- . sprintf('%010d', time())
- . sprintf('%06d', (float)microtime() * 1000000);
- }
- public function testMakeSn()
- {
- // $t = (float) microtime();
- // $x = sprintf('%03d', (float) microtime() * 1000);
- $sns = [];
- for ($index = 0; $index < 100000; $index++) {
- $sns[] = $this->make_sn();
- }
- $sns = array_unique($sns);
- $count = count($sns);
- }
- public function testMoney()
- {
- }
- public function testStaff()
- {
- $staffs = lrlz_staff();
- $type_sn = '36221506503801666595';
- bonus_helper::send_mobile($type_sn, $staffs);
- }
- public function testAndroidUrl()
- {
- $url = BASE_SITE_URL . '/data/upload/package/xmmz_release.apk';
- echo $url;
- }
- public function testLowestprice()
- {
-
- }
- }
|