TestStat.php 1.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172
  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/stat_helper.php');
  12. class TestStat extends PHPUnit_Framework_TestCase
  13. {
  14. public static function setUpBeforeClass()
  15. {
  16. Base::run_util();
  17. }
  18. public function testBonusPaid()
  19. {
  20. $param = ['time' => time(),'use_type' => 2,'rate' => 30,'amount' => 50,'member_id' => 0];
  21. stat_helper::onUseBonus($param);
  22. }
  23. public function testMember()
  24. {
  25. $cur_date = new DateTime();
  26. $cur_date->setDate(2016,8,20);
  27. $inter = new DateInterval('P1D');
  28. $cur_date->sub($inter);
  29. stat_helper::onDaiyMember($cur_date->getTimestamp());
  30. stat_helper::onDaiyBonus($cur_date->getTimestamp());
  31. stat_helper::onDaiyOrder($cur_date->getTimestamp());
  32. }
  33. public function testSelfDiscount()
  34. {
  35. stat_helper::onInitSelfDiscount();
  36. }
  37. public function testInviteeDiscount()
  38. {
  39. stat_helper::onInitInviteesDiscount();
  40. }
  41. public function testDailySelfDicount()
  42. {
  43. $cur_date = new DateTime();
  44. $inter = new DateInterval('P1D');
  45. $cur_date->sub($inter);
  46. stat_helper::onDailySelfDiscount($cur_date->getTimestamp());
  47. }
  48. public function testDailyInviteeDiscount()
  49. {
  50. }
  51. private function inviter($mod_member,$member_id)
  52. {
  53. $members = $mod_member->field('inviter_id')->where(['member_id' => $member_id])->limit(false)->select();
  54. if(empty($members)) {
  55. return false;
  56. }
  57. return intval($members[0]['member_id']);
  58. }
  59. public function testOme()
  60. {
  61. $x = "3.1.7";
  62. $y = intval($x * 100 + 0.5);
  63. }
  64. }