account_helperTest.php 4.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172
  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 testEvalu()
  74. {
  75. $data = [];
  76. $item['goods_id'] = 10;
  77. $item['score'] = 3;
  78. $item['comment'] = 'hello world';
  79. $item['images'][] = '/Users/stanley-king/work/PHPProject/shopnc/data/upload/uploadtmp/20161215080916-593ef137-923f-14c0-1307-118be24c9c0e.jpg';
  80. $data['goods'] = $item;
  81. $x = json_encode($data);
  82. $x = base64_encode($x);
  83. $y = json_decode($x,true);
  84. }
  85. public function testPaysuccess()
  86. {
  87. $pay_sn = '910510761110261481';
  88. account_helper::onPaySuccess($pay_sn);
  89. }
  90. public function testOrderSuccess()
  91. {
  92. $mod = Model('order');
  93. $pay_sn = '910510761110261481';
  94. $order_info = $mod->getOrderInfo(array('pay_sn' => $pay_sn));
  95. $logic_order = Logic('order');
  96. $result = $logic_order->changeOrderStateReceive($order_info,'system','系统','超期未收货系统自动完成订单');
  97. }
  98. public function testUpfile()
  99. {
  100. $file = '/Users/stanley-king/work/PHPProject/shopnc/data/upload/uploadtmp/20161215081131-53be4be9-fe01-50e7-28c0-ded900c9a0f6.jpg';
  101. $ext = exif_imagetype($file);
  102. $exif = image_type_to_mime_type($ext);
  103. $tagnmae = exif_tagname($ext);
  104. $info = new SplFileInfo($file);
  105. $type = $info->getType();
  106. $type = $info->getExtension();
  107. $size = $info->getSize();
  108. $tmp_name = $info->getFilename();
  109. }
  110. public function testTmpfile()
  111. {
  112. $file = '/private/var/tmp/php49DATg';
  113. $info = file($file);
  114. }
  115. public function testEvaluation()
  116. {
  117. $mod = Model();
  118. $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';
  119. $on = 'evaluate_goods.geval_frommemberid=member.member_id,goods.goods_id=evaluate_goods.geval_goodsid';
  120. $mod->table('evaluate_goods,member,goods')->field($field);
  121. $items = $mod->join('inner,left')->on($on)->where(array('evaluate_goods.geval_commonid' => 2188))->select();
  122. foreach ($items as $item)
  123. {
  124. $keyval = unserialize($item['goods_spec']);
  125. foreach ($keyval as $key => $val) {
  126. $goods_spec = $val;
  127. }
  128. }
  129. //spec =
  130. $x = 0;
  131. }
  132. public static function tearDownAfterClass()
  133. {
  134. }
  135. }