Index: trunk/phase3/maintenance/tests/phpunit/includes/search/SearchEngineTest.php |
— | — | @@ -44,12 +44,33 @@ |
45 | 45 | }*/ |
46 | 46 | } |
47 | 47 | |
| 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 | + |
48 | 72 | function fetchIds( $results ) { |
49 | 73 | $this->assertTrue( is_object( $results ) ); |
50 | 74 | |
51 | | - if ( $this->db->getType() !== 'mysql' && $this->db->getType() !== 'sqlite' ) { |
52 | | - $this->markTestSkipped( "MySQL or SQLite only" ); |
53 | | - } |
54 | 75 | $matches = array(); |
55 | 76 | while ( $row = $results->next() ) { |
56 | 77 | $matches[] = $row->getTitle()->getPrefixedText(); |
— | — | @@ -117,6 +138,7 @@ |
118 | 139 | } |
119 | 140 | |
120 | 141 | function testFullWidth() { |
| 142 | + $this->skipIfUnsupportedByDatabase(); |
121 | 143 | $this->assertEquals( |
122 | 144 | array( 'FullOneUp', 'FullTwoLow', 'HalfOneUp', 'HalfTwoLow' ), |
123 | 145 | $this->fetchIds( $this->search->searchText( 'AZ' ) ), |
— | — | @@ -136,6 +158,7 @@ |
137 | 159 | } |
138 | 160 | |
139 | 161 | function testTextSearch() { |
| 162 | + $this->skipIfUnsupportedByDatabase(); |
140 | 163 | $this->assertEquals( |
141 | 164 | array( 'Smithee' ), |
142 | 165 | $this->fetchIds( $this->search->searchText( 'smithee' ) ), |
— | — | @@ -143,6 +166,7 @@ |
144 | 167 | } |
145 | 168 | |
146 | 169 | function testTextPowerSearch() { |
| 170 | + $this->skipIfUnsupportedByDatabase(); |
147 | 171 | $this->search->setNamespaces( array( 0, 1, 4 ) ); |
148 | 172 | $this->assertEquals( |
149 | 173 | array( |
— | — | @@ -154,6 +178,7 @@ |
155 | 179 | } |
156 | 180 | |
157 | 181 | function testTitleSearch() { |
| 182 | + $this->skipIfUnsupportedByDatabase(); |
158 | 183 | $this->assertEquals( |
159 | 184 | array( |
160 | 185 | 'Alan Smithee', |
— | — | @@ -164,6 +189,7 @@ |
165 | 190 | } |
166 | 191 | |
167 | 192 | function testTextTitlePowerSearch() { |
| 193 | + $this->skipIfUnsupportedByDatabase(); |
168 | 194 | $this->search->setNamespaces( array( 0, 1, 4 ) ); |
169 | 195 | $this->assertEquals( |
170 | 196 | array( |