123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178 |
- <?php
- declare(strict_types=1);
- use PHPUnit\Framework\TestCase;
- define('APP_ID','test');
- define('BASE_ROOT_PATH',str_replace('/test','',dirname(__FILE__)));
- require_once(BASE_ROOT_PATH . '/global.php');
- require_once(BASE_CORE_PATH . '/lrlz.php');
- require_once(BASE_ROOT_PATH . '/helper/event_looper.php');
- require_once(BASE_ROOT_PATH . '/helper/search/processor.php');
- require_once(BASE_ROOT_PATH . '/helper/search/tcp_client.php');
- require_once(BASE_ROOT_PATH . '/helper/search/util.php');
- require_once(BASE_ROOT_PATH . '/helper/category_helper.php');
- require_once(BASE_ROOT_PATH . '/helper/search/searcher.php');
- require_once(BASE_ROOT_PATH . '/helper/brand_helper.php');
- require_once(BASE_ROOT_PATH . '/helper/algorithm.php');
- require_once(BASE_ROOT_PATH . '/helper/special_helper.php');
- define('MOBILE_SERVER',true);
- define('TIME_STAMP',time());
- class TestSearch extends TestCase
- {
- public static function setUpBeforeClass() : void
- {
- Base::run_util();
- }
- public function testFilter()
- {
- $words = search\word_segment::filter('哈English 文化');
- }
- public function testInit()
- {
- $dict = new search\goods_dict();
- $dict->init();
- }
- public function testHot()
- {
- $dict = new search\category_dict();
- }
- public function testBrand()
- {
- $dict = new search\brand_dict();
- }
- public function testSearcher()
- {
- $searcher = new search\searcher();
- $searcher->init();
- for($i = 0; $i < 10; ++$i) {
- $result = $searcher->get_result(array('keyword' => '', 'brand_id' => 0,'hot_id' => 11,'order' => 'price', 'sort' => 'desc', 'page_no' => 1, 'page_size' => 10));
- $result = $searcher->get_word('茱莉');
- }
- }
- public function testArea()
- {
- $result = search\search_client::instance()->get_area(37);
- }
- public function testRequest()
- {
- $result = search\search_client::instance()->get_result(['keyword' => 'bb']);
- }
- public function testBrandSpecia()
- {
- $brands = new brands_special();
- $ret = $brands->info(4);
- }
- public function testGoods()
- {
- $mod = Model('goods');
- $items = $mod->getGoodsOnlineList(array(), "*", '', '', false);
- $mod_common = Model("goods_common");
- $items = $mod->field("*")->limit(false)->select();
- }
- public function testUasort()
- {
- $words = [];
- $words[] = array("add_time" => 104,"count" => 1);
- $words[] = array("add_time" => 100,"count" => 1);
- $words[] = array("add_time" => 300,"count" => 1);
- $ret = uasort($words,'comp_time');
- foreach ($words as $key => $val) {
- echo $key;
- }
- }
- public function testHotsearch()
- {
- $x = @explode(',',C('hot_search'));//热门搜索
- $goodslist = Model('goods_browse')->getGuessLikeGoods(36490,10);
- }
- public function testUnion()
- {
- $a1 = array(1,3,5,7,9);
- $a2 = array(1,2,3,5,8,9);
- $result = algorithm::set_union($a1,$a2);
- }
- public function testUnionx()
- {
- $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>';
- $y = stripslashes($x);
- preg_match('#(.*?)<a href=".*?"\s+title="(.*?)".*?>.*?</a>#s',$x,$matches);
- $host = $matches[2];
- }
- public function testParams()
- {
- $params = array("xxx" => 1);
- $params = json_encode($params);
- $data = array('action' => 'groupbuy','params' => array('pay_sn' => 'fdfdsafdas'));
- $data = json_encode($data);
- }
- public function testNull()
- {
- $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";}}}';
- $y = unserialize($x);
- }
- public function testDefine()
- {
- $i = 0;
- while ( $i < 5) {
- sleep(1);
- echo "{i} " . TIME_STAMP . "\n";
- ++$i;
- }
- }
- public function testNotin()
- {
- $x = array(1,3,4,9,8,5);
- $y = array(3,2,3,4,9,8);
- $z = algorithm::not_in($x,$y);
- }
- public function testPasswd()
- {
- $x = md5('panda@qaz@makeup');
- $y = md5('xmmz@20161104');
- }
- public function testTime()
- {
- list($usec, $sec) = explode(" ", microtime());
- $t = time();
- $x = intval(microtime(true) * 10000);
- $y = intval(microtime(true) * 10000);
- $k = $y - $x;
- $z = microtime(true);
- $w = microtime(true);
- echo ($y - $x);
- }
- public function testPing()
- {
- $val = '🐳🐳🐳²₀¹₇';
- $info['alpha'] = Pinyin::getAlpha($val);
- }
- }
|