r91027 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r91026‎ | r91027 | r91028 >
Date:22:26, 28 June 2011
Author:demon
Status:ok
Tags:
Comment:
Merge SearchDbTest into SearchEngineTest. No real need for two classes here anymore, and it's kind of confusing if you try to run the stub by itself.
Also did some misc. cleanup while I was here

Results: OK (5 tests, 16 assertions)
Modified paths:
  • /trunk/phase3/tests/phpunit/includes/search/SearchDbTest.php (deleted) (history)
  • /trunk/phase3/tests/phpunit/includes/search/SearchEngineTest.php (modified) (history)

Diff [purge]

Index: trunk/phase3/tests/phpunit/includes/search/SearchDbTest.php
@@ -1,35 +0,0 @@
2 -<?php
3 -
4 -require_once( dirname( __FILE__ ) . '/SearchEngineTest.php' );
5 -
6 -/**
7 - * @group Search
8 - * @group Database
9 - * @group Destructive
10 - */
11 -class SearchDbTest extends SearchEngineTest {
12 - var $db;
13 -
14 - function setUp() {
15 - // Get a database connection or skip test
16 - $this->db = wfGetDB( DB_MASTER );
17 - if ( !$this->db ) {
18 - $this->markTestIncomplete( "Can't find a database to test with." );
19 - }
20 -
21 - parent::setup();
22 -
23 - // Initialize search database with data
24 - $GLOBALS['wgContLang'] = new Language;
25 - $this->insertSearchData();
26 - $searchType = $this->db->getSearchEngine();
27 - $this->search = new $searchType( $this->db );
28 - }
29 -
30 - function tearDown() {
31 - $this->removeSearchData();
32 - unset( $this->search );
33 - }
34 -}
35 -
36 -
Index: trunk/phase3/tests/phpunit/includes/search/SearchEngineTest.php
@@ -3,17 +3,21 @@
44 /**
55 * This class is not directly tested. Instead it is extended by SearchDbTest.
66 * @group Search
7 - * @group Stub
8 - * @group Destructive
 7+ * @group Database
98 */
109 class SearchEngineTest extends MediaWikiTestCase {
11 - var $db, $search, $pageList;
 10+ protected $search, $pageList;
1211
 12+ function tearDown() {
 13+ unset( $this->search );
 14+ }
 15+
1316 /*
1417 * Checks for database type & version.
1518 * Will skip current test if DB does not support search.
1619 */
1720 function setUp() {
 21+ parent::setUp();
1822 // Search tests require MySQL or SQLite with FTS
1923 # Get database type and version
2024 $dbType = $this->db->getType();
@@ -24,13 +28,16 @@
2529 if( !$dbSupported ) {
2630 $this->markTestSkipped( "MySQL or SQLite with FTS3 only" );
2731 }
 32+
 33+ $searchType = $this->db->getSearchEngine();
 34+ $this->search = new $searchType( $this->db );
2835 }
2936
3037 function pageExists( $title ) {
3138 return false;
3239 }
3340
34 - function insertSearchData() {
 41+ function addDBData() {
3542 if ( $this->pageExists( 'Not_Main_Page' ) ) {
3643 return;
3744 }
@@ -53,15 +60,6 @@
5461 $this->insertPage( 'DomainName', 'example.com', 0 );
5562 }
5663
57 - function removeSearchData() {
58 - return;
59 - /*while ( count( $this->pageList ) ) {
60 - list( $title, $id ) = array_pop( $this->pageList );
61 - $article = new Article( $title, $id );
62 - $article->doDeleteArticle( "Search Test" );
63 - }*/
64 - }
65 -
6664 function fetchIds( $results ) {
6765 $this->assertTrue( is_object( $results ) );
6866

Status & tagging log