TestSearch.php 1.5 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465
  1. <?php
  2. /**
  3. * Created by PhpStorm.
  4. * User: stanley-king
  5. * Date: 2016/10/7
  6. * Time: 下午1:03
  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/search/searcher.php');
  11. require_once(BASE_ROOT_PATH . '/helper/search/server.php');
  12. require_once(BASE_ROOT_PATH . '/helper/search/processor.php');
  13. require_once(BASE_ROOT_PATH . '/helper/search/tcp_client.php');
  14. require_once(BASE_ROOT_PATH . '/helper/category_helper.php');
  15. class TestSearch extends PHPUnit_Framework_TestCase
  16. {
  17. public static function setUpBeforeClass()
  18. {
  19. Base::run_util();
  20. }
  21. public function testInit()
  22. {
  23. $dict = new search\goods_dict();
  24. $dict->init();
  25. }
  26. public function testSearcher()
  27. {
  28. $searcher = new search\searcher();
  29. $result = $searcher->get_result('眼光影');
  30. }
  31. public function testRequest()
  32. {
  33. $result = search\tcp_client::instance()->get_result('眼影');
  34. }
  35. public function testUasort()
  36. {
  37. $words = [];
  38. $words[] = array("add_time" => 104,"count" => 1);
  39. $words[] = array("add_time" => 100,"count" => 1);
  40. $words[] = array("add_time" => 300,"count" => 1);
  41. $ret = uasort($words,'comp_time');
  42. foreach ($words as $key => $val) {
  43. echo $key;
  44. }
  45. }
  46. public function testUnion()
  47. {
  48. $a1 = array(1,3,5,7,9);
  49. $a2 = array(1,2,3,5,8,9);
  50. $result = algorithm::set_union($a1,$a2);
  51. }
  52. }