X-Git-Url: http://git.cyclocoop.org/?a=blobdiff_plain;ds=sidebyside;f=tests%2Fphpunit%2Fincludes%2Fsearch%2FSearchEngineTest.php;h=3da1361530f584c1636917d8469d6a3575c9790e;hb=26ded3a5458dbb00a561fb538d3e1597557419c4;hp=e4605911f004090a9d85730f282f780ea4318907;hpb=53e30990a59c233c0d72cde674431641df24c859;p=lhc%2Fweb%2Fwiklou.git diff --git a/tests/phpunit/includes/search/SearchEngineTest.php b/tests/phpunit/includes/search/SearchEngineTest.php index e4605911f0..3da1361530 100644 --- a/tests/phpunit/includes/search/SearchEngineTest.php +++ b/tests/phpunit/includes/search/SearchEngineTest.php @@ -8,10 +8,12 @@ * @note Coverage will only ever show one of on of the Search* classes */ class SearchEngineTest extends MediaWikiLangTestCase { + /** * @var SearchEngine */ protected $search; + protected $pageList; /** @@ -22,17 +24,23 @@ class SearchEngineTest extends MediaWikiLangTestCase { 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 ); } @@ -42,22 +50,18 @@ class SearchEngineTest extends MediaWikiLangTestCase { 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( "Not_Main_Page", "This is not a main page", 0 ); - $this->insertPage( 'Talk:Not_Main_Page', 'This is not a talk page to the main page, see [[smithee]]', 1 ); + $this->insertPage( + 'Talk:Not_Main_Page', + 'This is not a talk page to the main page, see [[smithee]]', + 1 + ); $this->insertPage( 'Smithee', 'A smithee is one who smiths. See also [[Alan Smithee]]', 0 ); $this->insertPage( 'Talk:Smithee', 'This article sucks.', 1 ); $this->insertPage( 'Unrelated_page', 'Nothing in this page is about the S word.', 0 ); @@ -75,12 +79,11 @@ class SearchEngineTest extends MediaWikiLangTestCase { $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(); @@ -101,11 +104,11 @@ class SearchEngineTest extends MediaWikiLangTestCase { /** * Insert a new page * - * @param $pageName String: page name - * @param $text String: page's content - * @param $n Integer: unused + * @param string $pageName Page name + * @param string $text Page's content + * @param int $ns Unused */ - function insertPage( $pageName, $text, $ns ) { + protected function insertPage( $pageName, $text, $ns ) { $title = Title::newFromText( $pageName, $ns ); $user = User::newFromName( 'WikiSysop' ); @@ -180,4 +183,5 @@ class SearchEngineTest extends MediaWikiLangTestCase { $this->fetchIds( $this->search->searchTitle( 'smithee' ) ), "Title power search failed" ); } + }