jenkins-bot has submitted this change and it was merged. (
https://gerrit.wikimedia.org/r/325054 )
Change subject: tests: Clean up PHPUnit tests
......................................................................
tests: Clean up PHPUnit tests
* Remove unused code.
* Move Provide class into dblistTest method per our code conventions.
Change-Id: I727d150dff198cba8293a2fe1d338f15718c8e79
---
M tests/DBList.php
D tests/Provide.php
M tests/bootstrap.php
M tests/cirrusTest.php
M tests/dblistTest.php
M tests/multiversion/MWMultiVersionTest.php
M tests/multiversion/MWRealmTest.php
7 files changed, 49 insertions(+), 80 deletions(-)
Approvals:
Krinkle: Looks good to me, approved
jenkins-bot: Verified
diff --git a/tests/DBList.php b/tests/DBList.php
index 768c2b5..d1cfb31 100644
--- a/tests/DBList.php
+++ b/tests/DBList.php
@@ -7,7 +7,7 @@
* @copyright Copyright © 2012, Antoine Musso <hashar at free dot fr>
* @file
*/
-require_once( __DIR__ . '/../multiversion/MWWikiversions.php' );
+require_once __DIR__ . '/../multiversion/MWWikiversions.php';
class DBList {
# List of project names. This array is used to verify that the various
@@ -22,21 +22,17 @@
'wiktionary',
);
- public static function getall() {
+ public static function getLists() {
static $list = null;
- if( $list ) {
- return $list;
- }
-
- $objects = scandir( dirname( __DIR__ ) . '/dblists' );
- foreach( $objects as $filename ) {
- if( substr( $filename, -7, 7 ) == '.dblist' ) {
- $projectname = substr( $filename, 0, -7 );
- # Happilly prefetch the files content
- $list[$projectname] =
MWWikiversions::readDbListFile( $filename );
+ if ( !$list ) {
+ $filenames = scandir( dirname( __DIR__ ) . '/dblists'
);
+ foreach ( $filenames as $filename ) {
+ if ( substr( $filename, -7, 7 ) == '.dblist' ) {
+ $projectname = substr( $filename, 0, -7
);
+ $list[$projectname] =
MWWikiversions::readDbListFile( $filename );
+ }
}
}
-
return $list;
}
diff --git a/tests/Provide.php b/tests/Provide.php
deleted file mode 100644
index e0bb333..0000000
--- a/tests/Provide.php
+++ /dev/null
@@ -1,30 +0,0 @@
-<?php
-/**
- * Generic providers for the 'WMF MediaWiki configuration' test suite.
- *
- * Inspired by MediaWiki tests/includes/Providers.php
- *
- * @license GPPLv2 or later
- * @author Antoine Musso
- * @copyright Copyright © 2012, Antoine Musso <hashar at free dot fr>
- * @file
- */
-
-class Provide {
- function ProjectsDatabases() {
- $cases=array();
- foreach( DBList::getall() as $projectname => $databases ) {
- if( !DBlist::isWikiProject( $projectname ) ) {
- # Skip files such as s1, private ...
- continue;
- }
- foreach( $databases as $database ) {
- $cases[] = array(
- $projectname, $database
- );
- }
- }
- return $cases;
- }
-
-}
diff --git a/tests/bootstrap.php b/tests/bootstrap.php
index 438824e..d111b5d 100644
--- a/tests/bootstrap.php
+++ b/tests/bootstrap.php
@@ -2,5 +2,4 @@
// Load the shared utilities classes from here!
require_once __DIR__ . "/DBList.php";
-require_once __DIR__ . "/Provide.php";
require_once __DIR__ . "/Defines.php";
diff --git a/tests/cirrusTest.php b/tests/cirrusTest.php
index aa305b1..e40ba44 100644
--- a/tests/cirrusTest.php
+++ b/tests/cirrusTest.php
@@ -67,12 +67,12 @@
public function testLanguageMatrix() {
$config = $this->loadCirrusConfig( 'production', 'enwiki',
'wiki' );
- $allDbs = DBList::getall();
+ $lists = DBList::getLists();
foreach( $config['wgCirrusSearchLanguageToWikiMap'] as $lang =>
$wiki ) {
$this->assertArrayHasKey( $wiki,
$config['wgCirrusSearchWikiToNameMap'] );
$wikiName =
$config['wgCirrusSearchWikiToNameMap'][$wiki];
- $this->assertContains( $wikiName, $allDbs['wikipedia']
);
+ $this->assertContains( $wikiName, $lists['wikipedia'] );
}
}
diff --git a/tests/dblistTest.php b/tests/dblistTest.php
index ea3c78d..0f0b39d 100644
--- a/tests/dblistTest.php
+++ b/tests/dblistTest.php
@@ -10,54 +10,57 @@
class DbListTests extends PHPUnit_Framework_TestCase {
- private $initDone = false;
- # Contains the db list filenames (ex: foobar.dblist) as key and an
array of
- # lines as values.
- # Never modify it outside of ->init()
- private $db;
+ public static function provideProjectDbnames() {
+ $cases = array();
+ foreach ( DBList::getLists() as $projectname => $databases ) {
+ if ( !DBlist::isWikiProject( $projectname ) ) {
+ // Skip files such as s1, private ...
+ continue;
+ }
+ foreach ( $databases as $database ) {
+ $cases[] = array(
+ $projectname, $database
+ );
+ }
+ }
+ return $cases;
+ }
/**
* Projects dblist should only contains databasenames which
* belongs to them.
*
- * @dataProvider Provide::ProjectsDatabases
+ * @dataProvider provideProjectDbnames
*/
- function testDatabaseNamesUseProjectNameAsSuffix( $projectname,
$database ) {
+ public function testDatabaseNamesUseProjectNameAsSuffix( $projectname,
$database ) {
- # Override suffix for wikipedia project
+ // Override suffix for wikipedia project
$dbsuffix = ( $projectname === 'wikipedia' )
? 'wiki'
: $projectname
;
- # Verifiy the databasename suffix
+ // Verifiy the databasename suffix
$this->assertStringEndsWith( $dbsuffix, $database,
"Database name $database lacks db suffix $dbsuffix of
$projectname"
);
}
+ public function testDblistAllContainsEverything() {
+ $lists = DBList::getLists();
- /**
- * FIXME we want to keep continuing showing errors
- */
- function testDblistAllContainsAllDatabaseNames() {
- $dbs = DBList::getall();
+ // Content of all.dblist
+ $all = $lists['all'];
- # Content of all.dblist
- $all = $dbs['all'];
- # No point in checking that the db listed in 'all' are contained
- # in 'all':
- unset( $dbs['all']);
-
- # dblist files we are just ignoring/skipping
- # FIXME ideally we want to clean those files from any old
dbnames
+ // dblist files that are exceptions
$skip = array(
+ // No point in checking all includes itself
+ 'all',
- # 'all-labs' and 'flow_only_labs' are for the 'beta'
project, which
- # has wikis not yet available in production ('all'). So
we do not
- # verify it.
+ // 'all-labs' and 'flow_only_labs' are for
beta.wmflabs.org only,
+ // which may have wikis not (yet) in production.
'all-labs',
'flow_computed_labs',
'flow_only_labs',
@@ -71,14 +74,15 @@
'todo',
);
- foreach( $dbs as $dbfile => $dbnames ) {
- if( in_array( $dbfile, $skip ) ) {
+ foreach ( $lists as $dbfile => $dbnames ) {
+ if ( in_array( $dbfile, $skip ) ) {
continue;
}
- $this->assertEquals( array()
- , array_diff( $dbnames, $all )
- , "'{$dbfile}.dblist' contains names not in
'all.dblist'"
+ $this->assertEquals(
+ array(),
+ array_diff( $dbnames, $all ),
+ "'{$dbfile}.dblist' contains names not in
'all.dblist'"
);
}
@@ -87,7 +91,7 @@
/**
* @covers MWWikiversions::evalDbListExpression
*/
- function testEvalDbListExpression() {
+ public function testEvalDbListExpression() {
$allDbs = MWWikiversions::readDbListFile( 'all' );
$allLabsDbs = MWWikiversions::readDbListFile( 'private' );
$exprDbs = MWWikiversions::evalDbListExpression( 'all -
private' );
diff --git a/tests/multiversion/MWMultiVersionTest.php
b/tests/multiversion/MWMultiVersionTest.php
index 21ffb8c..d95615b 100644
--- a/tests/multiversion/MWMultiVersionTest.php
+++ b/tests/multiversion/MWMultiVersionTest.php
@@ -1,7 +1,7 @@
<?php
-require_once( __DIR__ . '/../../multiversion/MWMultiVersion.php' );
-require_once( __DIR__ . '/../../multiversion/MWWikiversions.php' );
+require_once __DIR__ . '/../../multiversion/MWMultiVersion.php';
+require_once __DIR__ . '/../../multiversion/MWWikiversions.php';
class MWMultiVersionTests extends PHPUnit_Framework_TestCase {
diff --git a/tests/multiversion/MWRealmTest.php
b/tests/multiversion/MWRealmTest.php
index b5c7df8..aaffbc6 100644
--- a/tests/multiversion/MWRealmTest.php
+++ b/tests/multiversion/MWRealmTest.php
@@ -1,6 +1,6 @@
<?php
-require_once( __DIR__ . '/../../multiversion/MWRealm.php' );
+require_once __DIR__ . '/../../multiversion/MWRealm.php';
class MWRealmTests extends PHPUnit_Framework_TestCase {
--
To view, visit https://gerrit.wikimedia.org/r/325054
To unsubscribe, visit https://gerrit.wikimedia.org/r/settings
Gerrit-MessageType: merged
Gerrit-Change-Id: I727d150dff198cba8293a2fe1d338f15718c8e79
Gerrit-PatchSet: 4
Gerrit-Project: operations/mediawiki-config
Gerrit-Branch: master
Gerrit-Owner: Krinkle <[email protected]>
Gerrit-Reviewer: Catrope <[email protected]>
Gerrit-Reviewer: Chad <[email protected]>
Gerrit-Reviewer: Gilles <[email protected]>
Gerrit-Reviewer: Jforrester <[email protected]>
Gerrit-Reviewer: Krinkle <[email protected]>
Gerrit-Reviewer: Legoktm <[email protected]>
Gerrit-Reviewer: jenkins-bot <>
_______________________________________________
MediaWiki-commits mailing list
[email protected]
https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits