*/
public static function getSearchTypes() {
global $wgSearchType, $wgSearchTypeAlternatives;
- static $alternatives = null;
- if ( $alternatives === null ) {
- $alternatives = $wgSearchTypeAlternatives ?: array();
- array_unshift( $alternatives, $wgSearchType );
- }
+
+ $alternatives = $wgSearchTypeAlternatives ?: array();
+ array_unshift( $alternatives, $wgSearchType );
+
return $alternatives;
}
* @note Coverage will only ever show one of on of the Search* classes
*/
class SearchEngineTest extends MediaWikiLangTestCase {
+
/**
* @var SearchEngine
*/
protected $search;
+
protected $pageList;
/**
parent::setUp();
// Search tests require MySQL or SQLite with FTS
- # Get database type and version
$dbType = $this->db->getType();
- $dbSupported =
- ( $dbType === 'mysql' )
- || ( $dbType === 'sqlite' && $this->db->getFulltextSearchModule() == 'FTS3' );
+ $dbSupported = ( $dbType === 'mysql' )
+ || ( $dbType === 'sqlite' && $this->db->getFulltextSearchModule() == 'FTS3' );
if ( !$dbSupported ) {
$this->markTestSkipped( "MySQL or SQLite with FTS3 only" );
}
$searchType = $this->db->getSearchEngine();
+ $this->setMwGlobals( array(
+ 'wgSearchType' => $searchType
+ ) );
+
+ if ( !isset( self::$pageList ) ) {
+ $this->addPages();
+ }
+
$this->search = new $searchType( $this->db );
}
parent::tearDown();
}
- function pageExists( $title ) {
- return false;
- }
-
- function addDBData() {
- if ( $this->pageExists( 'Not_Main_Page' ) ) {
- return;
- }
-
+ protected function addPages() {
if ( !$this->isWikitextNS( NS_MAIN ) ) {
// @todo cover the case of non-wikitext content in the main namespace
return;
$this->insertPage( 'DomainName', 'example.com', 0 );
}
- function fetchIds( $results ) {
+ protected function fetchIds( $results ) {
if ( !$this->isWikitextNS( NS_MAIN ) ) {
$this->markTestIncomplete( __CLASS__ . " does no yet support non-wikitext content "
. "in the main namespace" );
}
-
$this->assertTrue( is_object( $results ) );
$matches = array();
* @param $text String: page's content
* @param $n Integer: unused
*/
- function insertPage( $pageName, $text, $ns ) {
+ protected function insertPage( $pageName, $text, $ns ) {
$title = Title::newFromText( $pageName, $ns );
$user = User::newFromName( 'WikiSysop' );
$this->fetchIds( $this->search->searchTitle( 'smithee' ) ),
"Title power search failed" );
}
+
}