r74787 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r74786‎ | r74787 | r74788 >
Date:18:01, 14 October 2010
Author:hashar
Status:resolved (Comments)
Tags:
Comment:
* sqlite 3.3 fails, raising version to 3.6 just like parserTests.php
* skip tests that need DB support

Maybe someone could implements this using the magic __call method.
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
@@ -44,12 +44,33 @@
4545 }*/
4646 }
4747
 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+
4872 function fetchIds( $results ) {
4973 $this->assertTrue( is_object( $results ) );
5074
51 - if ( $this->db->getType() !== 'mysql' && $this->db->getType() !== 'sqlite' ) {
52 - $this->markTestSkipped( "MySQL or SQLite only" );
53 - }
5475 $matches = array();
5576 while ( $row = $results->next() ) {
5677 $matches[] = $row->getTitle()->getPrefixedText();
@@ -117,6 +138,7 @@
118139 }
119140
120141 function testFullWidth() {
 142+ $this->skipIfUnsupportedByDatabase();
121143 $this->assertEquals(
122144 array( 'FullOneUp', 'FullTwoLow', 'HalfOneUp', 'HalfTwoLow' ),
123145 $this->fetchIds( $this->search->searchText( 'AZ' ) ),
@@ -136,6 +158,7 @@
137159 }
138160
139161 function testTextSearch() {
 162+ $this->skipIfUnsupportedByDatabase();
140163 $this->assertEquals(
141164 array( 'Smithee' ),
142165 $this->fetchIds( $this->search->searchText( 'smithee' ) ),
@@ -143,6 +166,7 @@
144167 }
145168
146169 function testTextPowerSearch() {
 170+ $this->skipIfUnsupportedByDatabase();
147171 $this->search->setNamespaces( array( 0, 1, 4 ) );
148172 $this->assertEquals(
149173 array(
@@ -154,6 +178,7 @@
155179 }
156180
157181 function testTitleSearch() {
 182+ $this->skipIfUnsupportedByDatabase();
158183 $this->assertEquals(
159184 array(
160185 'Alan Smithee',
@@ -164,6 +189,7 @@
165190 }
166191
167192 function testTextTitlePowerSearch() {
 193+ $this->skipIfUnsupportedByDatabase();
168194 $this->search->setNamespaces( array( 0, 1, 4 ) );
169195 $this->assertEquals(
170196 array(

Follow-up revisions

RevisionCommit summaryAuthorDate
r74790Fixes for r74787:...maxsem18:27, 14 October 2010

Comments

#Comment by 😂 (talk | contribs)   18:04, 14 October 2010

You could just make the first test testSupportByDB() and then add a "@depends testSupportByDB" to the docblocks for subsequent tests. PHPUnit magic will skip them :)

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

I prefered having the test in setup(). This is less error prone and more transparent than relaying on adding a comment (@depends) or a function call (skipIfUnsupportedByDatabase()).

r74832 fixed it, so we might want to mark this revision ok :)

Status & tagging log