[ Index ] |
PHP Cross Reference of DokuWiki |
[Summary view] [Print] [Text view]
1 <?php 2 3 // must be run within Dokuwiki 4 if (!defined('DOKU_INC')) { 5 die(); 6 } 7 8 /** 9 * Test cases for the link index 10 * 11 * @author Michael Große <grosse@cosmocode.de> 12 * 13 * @group fulltext 14 */ 15 class fulltext_query_test extends DokuWikiTest 16 { 17 public function test_parse_query() 18 { 19 $Indexer = idx_get_indexer(); 20 $inputQuery = 'test -baz "foo bar" @abc ^def'; 21 22 $actualParsedQuery = ft_queryParser($Indexer, $inputQuery); 23 24 $expectedParsedQuery = [ 25 'query' => 'test -baz "foo bar" @abc ^def', 26 'parsed_str' => '(W+:test)ANDNOT((W-:baz))AND((W_:foo)AND(W_:bar)AND(P+:foo bar))AND(N+:abc)ANDNOT(N-:def)', 27 'parsed_ary' => [ 28 'W+:test', 29 'W-:baz', 30 'NOT', 31 'AND', 32 'W_:foo', 33 'W_:bar', 34 'AND', 35 'P+:foo bar', 36 'AND', 37 'AND', 38 'N+:abc', 39 'AND', 40 'N-:def', 41 'NOT', 42 'AND', 43 ], 44 'words' => [ 45 'test', 46 'baz', 47 'foo', 48 'bar', 49 ], 50 'highlight' => [ 51 'test', 52 'foo bar', 53 ], 54 'and' => [ 55 'test', 56 ], 57 'phrases' => [ 58 'foo bar', 59 ], 60 'ns' => [ 61 'abc', 62 ], 63 'notns' => [ 64 'def', 65 ], 66 'not' => [ 67 'baz', 68 ], 69 ]; 70 $this->assertEquals($expectedParsedQuery, $actualParsedQuery); 71 } 72 73 public function test_unparse_query() 74 { 75 $input = [ 76 'and' => [ 77 'test', 78 ], 79 'not' => [ 80 'baz' 81 ], 82 'phrases' => [ 83 'foo bar', 84 ], 85 'ns' => [ 86 'abc', 87 ], 88 'notns' => [ 89 'def' 90 ], 91 ]; 92 93 $actualQuery = ft_queryUnparser_simple( 94 $input['and'], 95 $input['not'], 96 $input['phrases'], 97 $input['ns'], 98 $input['notns'] 99 ); 100 101 $expectedQuery = 'test -baz "foo bar" @abc ^def'; 102 $this->assertEquals($expectedQuery, $actualQuery); 103 } 104 }
title
Description
Body
title
Description
Body
title
Description
Body
title
Body