/** * 简单搜索测试 * @return void */ public function testSearch() { $this->info("\n\r........................start search............................\n\r"); $bank = new Bank(); $words = ['进口', '中式', 'zs', 'zhong', 'm', 'ji', '窗框', 'ck', 'pvc', 's', 'EVO', 'samsung']; $specialTakeCare = ['进口', '进k', '进ko', '进kou', 'j口', 'ji口', 'jin口', 'j', 'jk', 'jik', 'jink', 'jink', 'jinko', 'jinkou']; $insertWords = ['软包', 'rb', 'ru', 'rua', 'ruan', 'ruanb', 'ruanba', 'ruanbao']; $words = array_merge($words, $specialTakeCare, $insertWords); foreach ($words as $word) { $results = $bank->withdrawal($word); $this->comment("\n\r" . 'result..' . $word); foreach ($results as $result) { $this->info(' ' . $word . '=>' . $result); } } $this->info("........................ system search............................\n\r"); $suggest = new Suggest(); foreach ($words as $word) { $results = $suggest->search($word); $this->comment("\n\r" . 'result..' . $word); foreach ($results as $result) { $this->info(' ' . $word . '=>' . $result); } } $this->assertTrue(true); $this->info("........................ end search............................\n\r"); }
public function test_choose_redis() { $this->info('-- test choose detabase --'); $suggest = new Suggest($this->connect, ['database' => 13]); $results = $suggest->search("大理", self::TYPE_ONE); var_dump($results); $this->assertTrue(true); }
/** * test that choose database for store * * @return void */ public function test_choose_database_store() { $this->info("start different database store..."); $suggest = new Suggest($this->connect, ['database' => 13]); $suggest->clear(); $storeRecords = $this->getJson(); foreach ($storeRecords as $item) { $item['type'] = self::TYPE_ONE; $this->info($item['name']); $suggest->push($item, 'test'); } $this->info('withdrawal ' . count($storeRecords) . ' coin'); $this->assertTrue(true); }