TestSearch.php 5.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178
  1. <?php
  2. declare(strict_types=1);
  3. use PHPUnit\Framework\TestCase;
  4. define('APP_ID','test');
  5. define('BASE_ROOT_PATH',str_replace('/test','',dirname(__FILE__)));
  6. require_once(BASE_ROOT_PATH . '/global.php');
  7. require_once(BASE_CORE_PATH . '/lrlz.php');
  8. require_once(BASE_ROOT_PATH . '/helper/event_looper.php');
  9. require_once(BASE_ROOT_PATH . '/helper/search/processor.php');
  10. require_once(BASE_ROOT_PATH . '/helper/search/tcp_client.php');
  11. require_once(BASE_ROOT_PATH . '/helper/search/util.php');
  12. require_once(BASE_ROOT_PATH . '/helper/category_helper.php');
  13. require_once(BASE_ROOT_PATH . '/helper/search/searcher.php');
  14. require_once(BASE_ROOT_PATH . '/helper/brand_helper.php');
  15. require_once(BASE_ROOT_PATH . '/helper/algorithm.php');
  16. require_once(BASE_ROOT_PATH . '/helper/special_helper.php');
  17. define('MOBILE_SERVER',true);
  18. define('TIME_STAMP',time());
  19. class TestSearch extends TestCase
  20. {
  21. public static function setUpBeforeClass() : void
  22. {
  23. Base::run_util();
  24. }
  25. public function testFilter()
  26. {
  27. $words = search\word_segment::filter('哈English 文化');
  28. }
  29. public function testInit()
  30. {
  31. $dict = new search\goods_dict();
  32. $dict->init();
  33. }
  34. public function testHot()
  35. {
  36. $dict = new search\category_dict();
  37. }
  38. public function testBrand()
  39. {
  40. $dict = new search\brand_dict();
  41. }
  42. public function testSearcher()
  43. {
  44. $searcher = new search\searcher();
  45. $searcher->init();
  46. for($i = 0; $i < 10; ++$i) {
  47. $result = $searcher->get_result(array('keyword' => '', 'brand_id' => 0,'hot_id' => 11,'order' => 'price', 'sort' => 'desc', 'page_no' => 1, 'page_size' => 10));
  48. $result = $searcher->get_word('茱莉');
  49. }
  50. }
  51. public function testArea()
  52. {
  53. $result = search\search_client::instance()->get_area(37);
  54. }
  55. public function testRequest()
  56. {
  57. $result = search\search_client::instance()->get_result(['keyword' => 'bb']);
  58. }
  59. public function testBrandSpecia()
  60. {
  61. $brands = new brands_special();
  62. $ret = $brands->info(4);
  63. }
  64. public function testGoods()
  65. {
  66. $mod = Model('goods');
  67. $items = $mod->getGoodsOnlineList(array(), "*", '', '', false);
  68. $mod_common = Model("goods_common");
  69. $items = $mod->field("*")->limit(false)->select();
  70. }
  71. public function testUasort()
  72. {
  73. $words = [];
  74. $words[] = array("add_time" => 104,"count" => 1);
  75. $words[] = array("add_time" => 100,"count" => 1);
  76. $words[] = array("add_time" => 300,"count" => 1);
  77. $ret = uasort($words,'comp_time');
  78. foreach ($words as $key => $val) {
  79. echo $key;
  80. }
  81. }
  82. public function testHotsearch()
  83. {
  84. $x = @explode(',',C('hot_search'));//热门搜索
  85. $goodslist = Model('goods_browse')->getGuessLikeGoods(36490,10);
  86. }
  87. public function testUnion()
  88. {
  89. $a1 = array(1,3,5,7,9);
  90. $a2 = array(1,2,3,5,8,9);
  91. $result = algorithm::set_union($a1,$a2);
  92. }
  93. public function testUnionx()
  94. {
  95. $x = '满500减50 送<a href="http://192.168.0.200/shop/index.php?act=goods&op=index&goods_id=4550" title="妮维雅 冰爽透明防晒气雾 200ml 200ml" target="_blank">[赠品]</a>';
  96. $y = stripslashes($x);
  97. preg_match('#(.*?)<a href=".*?"\s+title="(.*?)".*?>.*?</a>#s',$x,$matches);
  98. $host = $matches[2];
  99. }
  100. public function testParams()
  101. {
  102. $params = array("xxx" => 1);
  103. $params = json_encode($params);
  104. $data = array('action' => 'groupbuy','params' => array('pay_sn' => 'fdfdsafdas'));
  105. $data = json_encode($data);
  106. }
  107. public function testNull()
  108. {
  109. $x = 'a:1:{s:4:"item";a:6:{s:25:"s61_05308797997352196.png";a:3:{s:5:"image";s:25:"s61_05308797997352196.png";s:4:"type";s:7:"special";s:4:"data";s:2:"53";}s:25:"s61_05308798368461066.png";a:3:{s:5:"image";s:25:"s61_05308798368461066.png";s:4:"type";s:7:"special";s:4:"data";s:2:"49";}s:25:"s61_05308798643188523.png";a:3:{s:5:"image";s:25:"s61_05308798643188523.png";s:4:"type";s:7:"special";s:4:"data";s:2:"50";}s:25:"s61_05308798882646585.png";a:3:{s:5:"image";s:25:"s61_05308798882646585.png";s:4:"type";s:7:"special";s:4:"data";s:2:"51";}s:25:"s61_05308799439510460.png";a:3:{s:5:"image";s:25:"s61_05308799439510460.png";s:4:"type";s:7:"special";s:4:"data";s:2:"46";}s:25:"s61_05308799642656955.png";a:3:{s:5:"image";s:25:"s61_05308799642656955.png";s:4:"type";s:7:"special";s:4:"data";s:2:"47";}}}';
  110. $y = unserialize($x);
  111. }
  112. public function testDefine()
  113. {
  114. $i = 0;
  115. while ( $i < 5) {
  116. sleep(1);
  117. echo "{i} " . TIME_STAMP . "\n";
  118. ++$i;
  119. }
  120. }
  121. public function testNotin()
  122. {
  123. $x = array(1,3,4,9,8,5);
  124. $y = array(3,2,3,4,9,8);
  125. $z = algorithm::not_in($x,$y);
  126. }
  127. public function testPasswd()
  128. {
  129. $x = md5('panda@qaz@makeup');
  130. $y = md5('xmmz@20161104');
  131. }
  132. public function testTime()
  133. {
  134. list($usec, $sec) = explode(" ", microtime());
  135. $t = time();
  136. $x = intval(microtime(true) * 10000);
  137. $y = intval(microtime(true) * 10000);
  138. $k = $y - $x;
  139. $z = microtime(true);
  140. $w = microtime(true);
  141. echo ($y - $x);
  142. }
  143. public function testPing()
  144. {
  145. $val = '🐳🐳🐳²₀¹₇';
  146. $info['alpha'] = Pinyin::getAlpha($val);
  147. }
  148. }