r74790 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r74789‎ | r74790 | r74791 >
Date:18:27, 14 October 2010
Author:maxsem
Status:resolved (Comments)
Tags:
Comment:
Fixes for r74787:
* Don't call the check from every tests, there's setup() for that
* Check for FTS3 presence for SQLite, version is only partially relevant here as full-text search was added to default build options in 3.5.3, but it was accessible even before that. And even on 3.6 people can choose not to build with FTS.
Modified paths:
  • /trunk/phase3/maintenance/tests/phpunit/includes/search/SearchEngineTest.php (modified) (history)

Diff [purge]

Index: trunk/phase3/maintenance/tests/phpunit/includes/search/SearchEngineTest.php
@@ -8,6 +8,25 @@
99 class SearchEngineTest extends MediaWikiTestSetup {
1010 var $db, $search, $pageList;
1111
 12+ /*
 13+ * Checks for database type & version.
 14+ * Will skip current test if DB does not support search.
 15+ */
 16+ function setup() {
 17+ // Get database type and version
 18+ $dbType = $this->db->getType();
 19+ $dbVersion = $this->db->getServerVersion();
 20+
 21+ // will skip unless mysql or sqlite with FTS
 22+ $dbSupported =
 23+ ($dbType === 'mysql')
 24+ || ( $dbType === 'sqlite' && $this->db->getFulltextSearchModule() == 'FTS3' );
 25+
 26+ if( !$dbSupported ) {
 27+ $this->markTestIgnored( "MySQL or SQLite with FTS3 only" );
 28+ }
 29+ }
 30+
1231 function pageExists( $title ) {
1332 return false;
1433 }
@@ -44,30 +63,6 @@
4564 }*/
4665 }
4766
48 - /*
49 - * Checks for database type & version.
50 - * Will skip current test if DB does not support search.
51 - */
52 - function skipIfUnsupportedByDatabase() {
53 - static $dbSupported;
54 -
55 - if( $dbSupported === null ) {
56 - // Get database type and version
57 - $dbType = $this->db->getType();
58 - $dbVersion = $this->db->getServerVersion();
59 -
60 - // will skip unless mysql or sqlite 3.6+
61 - $dbSupported =
62 - ($dbType === 'mysql')
63 - || ( $dbType === 'sqlite' && version_compare( $dbVersion, '3.6') > 0 )
64 - ;
65 - }
66 -
67 - if( !$dbSupported ) {
68 - $this->markTestSkipped( "MySQL or SQLite > 3.6 only" );
69 - }
70 - }
71 -
7267 function fetchIds( $results ) {
7368 $this->assertTrue( is_object( $results ) );
7469
@@ -138,7 +133,6 @@
139134 }
140135
141136 function testFullWidth() {
142 - $this->skipIfUnsupportedByDatabase();
143137 $this->assertEquals(
144138 array( 'FullOneUp', 'FullTwoLow', 'HalfOneUp', 'HalfTwoLow' ),
145139 $this->fetchIds( $this->search->searchText( 'AZ' ) ),
@@ -158,7 +152,6 @@
159153 }
160154
161155 function testTextSearch() {
162 - $this->skipIfUnsupportedByDatabase();
163156 $this->assertEquals(
164157 array( 'Smithee' ),
165158 $this->fetchIds( $this->search->searchText( 'smithee' ) ),
@@ -166,7 +159,6 @@
167160 }
168161
169162 function testTextPowerSearch() {
170 - $this->skipIfUnsupportedByDatabase();
171163 $this->search->setNamespaces( array( 0, 1, 4 ) );
172164 $this->assertEquals(
173165 array(
@@ -178,7 +170,6 @@
179171 }
180172
181173 function testTitleSearch() {
182 - $this->skipIfUnsupportedByDatabase();
183174 $this->assertEquals(
184175 array(
185176 'Alan Smithee',
@@ -189,7 +180,6 @@
190181 }
191182
192183 function testTextTitlePowerSearch() {
193 - $this->skipIfUnsupportedByDatabase();
194184 $this->search->setNamespaces( array( 0, 1, 4 ) );
195185 $this->assertEquals(
196186 array(

Follow-up revisions

RevisionCommit summaryAuthorDate
r74832* Fix r74790 by actually calling setup (using parent::setup)...hashar13:24, 16 October 2010

Past revisions this follows-up on

RevisionCommit summaryAuthorDate
r74787* sqlite 3.3 fails, raising version to 3.6 just like parserTests.php...hashar18:01, 14 October 2010

Comments

#Comment by Hashar (talk | contribs)   21:39, 14 October 2010

Tests are not skiped and fail! In my configuration, the setup() method is never called (PHPUnit 3.4.15)

#Comment by 😂 (talk | contribs)   21:41, 14 October 2010

I know method names are *supposed* to be case-insensitive. Does PHPUnit actually care and require setUp()?

In any case, the solution I proposed on r74787 would work too.

#Comment by Hashar (talk | contribs)   13:25, 16 October 2010

Resolved with r74832

Status & tagging log