$this->assertEquals(
[ 'Smithee' ],
$this->fetchIds( $this->search->searchText( 'smithee' ) ),
- "Plain search failed" );
+ "Plain search" );
+ }
+
+ public function testPhraseSearch() {
+ $res = $this->search->searchText( '"smithee is one who smiths"' );
+ $this->assertEquals(
+ [ 'Smithee' ],
+ $this->fetchIds( $res ),
+ "Search a phrase" );
+ $res = $this->search->searchText( '"smithee is one who smiths"' );
+ $match = $res->next();
+ $terms = [ 'smithee', 'is', 'one', 'who', 'smiths' ];
+ $snippet = "";
+ foreach ( $terms as $term ) {
+ $snippet .= " <span class='searchmatch'>" . $term . "</span>";
+ }
+ $this->assertRegexp( '/' . preg_quote( $snippet, '/' ) . '/',
+ $match->getTextSnippet( $res->termMatches() ),
+ "Highlight a phrase search" );
}
public function testTextPowerSearch() {
'Talk:Not Main Page',
],
$this->fetchIds( $this->search->searchText( 'smithee' ) ),
- "Power search failed" );
+ "Power search" );
}
public function testTitleSearch() {
'Smithee',
],
$this->fetchIds( $this->search->searchTitle( 'smithee' ) ),
- "Title search failed" );
+ "Title search" );
}
public function testTextTitlePowerSearch() {
'Talk:Smithee',
],
$this->fetchIds( $this->search->searchTitle( 'smithee' ) ),
- "Title power search failed" );
+ "Title power search" );
}
/**