account_helperTest.php 4.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165
  1. <?php
  2. /**
  3. * Created by PhpStorm.
  4. * User: stanley-king
  5. * Date: 16/6/27
  6. * Time: 下午10:27
  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/bonus_helper.php');
  11. require_once(BASE_ROOT_PATH . '/helper/account_helper.php');
  12. require_once(BASE_ROOT_PATH . '/helper/category_helper.php');
  13. require_once(BASE_ROOT_PATH . '/helper/brand_helper.php');
  14. class bar
  15. {
  16. public function __construct()
  17. {
  18. echo __FUNCTION__ . " \n";
  19. }
  20. public function __destruct()
  21. {
  22. echo __FUNCTION__ . " \n";
  23. }
  24. }
  25. class account_helperTest extends PHPUnit_Framework_TestCase
  26. {
  27. public static function setUpBeforeClass()
  28. {
  29. Base::run_util();
  30. }
  31. public function testPayRefund()
  32. {
  33. //account_helper::pay_refund(36490,500,'退款红包');
  34. }
  35. public function testModelCond()
  36. {
  37. $cur_time = time();
  38. $cond['usable_time'] = array(array('gt',$cur_time), array('elt',$cur_time + 200),'and');
  39. $cond['notify_time'] = array(array('eq',0), array('elt',$cur_time + 300),'or');
  40. $mod_bonus = Model('user_bonus');
  41. $X= $mod_bonus->field('bonus_id,usable_time as usabletm')->where($cond)->select();
  42. }
  43. public function testCondition()
  44. {
  45. $mod_type = Model('bonus_type');
  46. // $condition = array('sender_id' => 36490, 'relayer_id' => 36490, '_op' => 'or');
  47. // $condition = array($condition,array('make_type' => 0),'_op' => 'and');
  48. //$condition = "(sender_id=36490 or relayer_id => 36490) and (make_type = 0)";
  49. $member_id = 36490;
  50. $cond = array();
  51. $cond['sender_id|repayer_id'] = array('_multi'=>true,$member_id,36491);
  52. $cond['make_type'] = 0;
  53. $mod_type->where($cond)->select();
  54. }
  55. private function xxx()
  56. {
  57. $bar = new bar();
  58. }
  59. public function testDestruct()
  60. {
  61. echo __FUNCTION__ . " begin \n";
  62. $this->xxx();
  63. $bar = new bar();
  64. echo __FUNCTION__ . " end \n";
  65. }
  66. public function testBrands()
  67. {
  68. $url = '美宝莲-心机咬唇0727.mp4';
  69. $url = urlencode($url);
  70. $x = mt_rand(1,1);
  71. $brands = brand_helper::instance()->brandex();
  72. }
  73. public function testPaysuccess()
  74. {
  75. account_helper::paysuccess_bonus(38682,1000);
  76. $mod = Model('order');
  77. $info = $mod->getOrderInfo(array('pay_sn' => '740532913609644490'));
  78. $buyer_id = intval($info['buyer_id']);
  79. $goods_amount = intval($info['goods_amount']);
  80. }
  81. public function testEvalu()
  82. {
  83. $data = [];
  84. $item['goods_id'] = 10;
  85. $item['score'] = 3;
  86. $item['comment'] = 'hello world';
  87. $item['images'][] = '/Users/stanley-king/work/PHPProject/shopnc/data/upload/uploadtmp/20161215080916-593ef137-923f-14c0-1307-118be24c9c0e.jpg';
  88. $data['goods'] = $item;
  89. $x = json_encode($data);
  90. $x = base64_encode($x);
  91. $y = json_decode($x,true);
  92. }
  93. public function testUpfile()
  94. {
  95. $file = '/Users/stanley-king/work/PHPProject/shopnc/data/upload/uploadtmp/20161215081131-53be4be9-fe01-50e7-28c0-ded900c9a0f6.jpg';
  96. $ext = exif_imagetype($file);
  97. $exif = image_type_to_mime_type($ext);
  98. $tagnmae = exif_tagname($ext);
  99. $info = new SplFileInfo($file);
  100. $type = $info->getType();
  101. $type = $info->getExtension();
  102. $size = $info->getSize();
  103. $tmp_name = $info->getFilename();
  104. }
  105. public function testTmpfile()
  106. {
  107. $file = '/private/var/tmp/php49DATg';
  108. $info = file($file);
  109. }
  110. public function testEvaluation()
  111. {
  112. $mod = Model();
  113. $field = 'member.member_avatar,goods.goods_spec,evaluate_goods.geval_id,evaluate_goods.geval_commonid,evaluate_goods.geval_goodsid,evaluate_goods.geval_goodsname,evaluate_goods.geval_scores,evaluate_goods.geval_content,evaluate_goods.geval_isanonymous,evaluate_goods.geval_addtime,evaluate_goods.geval_frommemberid,evaluate_goods.geval_frommembername,evaluate_goods.geval_explain,evaluate_goods.geval_image';
  114. $on = 'evaluate_goods.geval_frommemberid=member.member_id,goods.goods_id=evaluate_goods.geval_goodsid';
  115. $mod->table('evaluate_goods,member,goods')->field($field);
  116. $items = $mod->join('inner,left')->on($on)->where(array('evaluate_goods.geval_commonid' => 2188))->select();
  117. foreach ($items as $item)
  118. {
  119. $keyval = unserialize($item['goods_spec']);
  120. foreach ($keyval as $key => $val) {
  121. $goods_spec = $val;
  122. }
  123. }
  124. //spec =
  125. $x = 0;
  126. }
  127. public static function tearDownAfterClass()
  128. {
  129. }
  130. }