[MediaWiki-commits] [Gerrit] mediawiki/core[wmf/1.30.0-wmf.7]: Add two new hooks to fix broken CentralAuth unit tests

2017-07-07 Thread jenkins-bot (Code Review)
jenkins-bot has submitted this change and it was merged. ( 
https://gerrit.wikimedia.org/r/363892 )

Change subject: Add two new hooks to fix broken CentralAuth unit tests
..


Add two new hooks to fix broken CentralAuth unit tests

* UnitTestsAfterDatabaseSetup
* UnitTestsBeforeDatabaseTeardown
Bug T168802 necessitates that CentralAuth creates its tables
before any user tests are run, due to its extensive hooking
into everything. This change adds two hooks for that, called
after DB initialization is done and before teardown begins. The
corresponding CentralAuth change is
at I618840fafd22d9b6471eb470ef0414e354aa17f5

Bug: T168802
Change-Id: If7050513719833d4167a24283885d7c10a25856b
(cherry picked from commit 9374590feac2e1c78565b790681e9afb966393c6)
---
M docs/hooks.txt
M tests/phpunit/MediaWikiTestCase.php
2 files changed, 14 insertions(+), 0 deletions(-)

Approvals:
  Legoktm: Looks good to me, approved
  jenkins-bot: Verified



diff --git a/docs/hooks.txt b/docs/hooks.txt
index 3d310c3..7cabbbc 100644
--- a/docs/hooks.txt
+++ b/docs/hooks.txt
@@ -3454,6 +3454,14 @@
 $title: title object related to the revision
 $rev: revision (object) that will be viewed
 
+'UnitTestsAfterDatabaseSetup': Called right after MediaWiki's test 
infrastructure
+has finished creating/duplicating core tables for unit tests.
+$database: Database in question
+$prefix: Table prefix to be used in unit tests
+
+'UnitTestsBeforeDatabaseTeardown': Called right before MediaWiki tears down its
+database infrastructure used for unit tests.
+
 'UnitTestsList': Called when building a list of paths containing PHPUnit tests.
 Since 1.24: Paths pointing to a directory will be recursively scanned for
 test case files matching the suffix "Test.php".
diff --git a/tests/phpunit/MediaWikiTestCase.php 
b/tests/phpunit/MediaWikiTestCase.php
index c1ada45..d804074 100644
--- a/tests/phpunit/MediaWikiTestCase.php
+++ b/tests/phpunit/MediaWikiTestCase.php
@@ -5,6 +5,8 @@
 use MediaWiki\Logger\MonologSpi;
 use MediaWiki\MediaWikiServices;
 use Psr\Log\LoggerInterface;
+use Wikimedia\Rdbms\IMaintainableDatabase;
+use Wikimedia\Rdbms\Database;
 use Wikimedia\TestingAccessWrapper;
 
 /**
@@ -1101,6 +1103,8 @@
return;
}
 
+   Hooks::run( 'UnitTestsBeforeDatabaseTeardown' );
+
foreach ( $wgJobClasses as $type => $class ) {
// Delete any jobs under the clone DB (or old prefix in 
other stores)
JobQueueGroup::singleton()->get( $type )->delete();
@@ -1203,6 +1207,8 @@
if ( $db->getType() == 'oracle' ) {
$db->query( 'BEGIN FILL_WIKI_INFO; END;' );
}
+
+   Hooks::run( 'UnitTestsAfterDatabaseSetup', [ $db, $prefix ] );
}
 
/**

-- 
To view, visit https://gerrit.wikimedia.org/r/363892
To unsubscribe, visit https://gerrit.wikimedia.org/r/settings

Gerrit-MessageType: merged
Gerrit-Change-Id: If7050513719833d4167a24283885d7c10a25856b
Gerrit-PatchSet: 1
Gerrit-Project: mediawiki/core
Gerrit-Branch: wmf/1.30.0-wmf.7
Gerrit-Owner: Legoktm 
Gerrit-Reviewer: Legoktm 
Gerrit-Reviewer: MaxSem 
Gerrit-Reviewer: jenkins-bot <>

___
MediaWiki-commits mailing list
MediaWiki-commits@lists.wikimedia.org
https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits


[MediaWiki-commits] [Gerrit] mediawiki/core[wmf/1.30.0-wmf.7]: Add two new hooks to fix broken CentralAuth unit tests

2017-07-07 Thread Legoktm (Code Review)
Legoktm has uploaded a new change for review. ( 
https://gerrit.wikimedia.org/r/363892 )

Change subject: Add two new hooks to fix broken CentralAuth unit tests
..

Add two new hooks to fix broken CentralAuth unit tests

* UnitTestsAfterDatabaseSetup
* UnitTestsBeforeDatabaseTeardown
Bug T168802 necessitates that CentralAuth creates its tables
before any user tests are run, due to its extensive hooking
into everything. This change adds two hooks for that, called
after DB initialization is done and before teardown begins. The
corresponding CentralAuth change is
at I618840fafd22d9b6471eb470ef0414e354aa17f5

Bug: T168802
Change-Id: If7050513719833d4167a24283885d7c10a25856b
(cherry picked from commit 9374590feac2e1c78565b790681e9afb966393c6)
---
M docs/hooks.txt
M tests/phpunit/MediaWikiTestCase.php
2 files changed, 14 insertions(+), 0 deletions(-)


  git pull ssh://gerrit.wikimedia.org:29418/mediawiki/core 
refs/changes/92/363892/1

diff --git a/docs/hooks.txt b/docs/hooks.txt
index 3d310c3..7cabbbc 100644
--- a/docs/hooks.txt
+++ b/docs/hooks.txt
@@ -3454,6 +3454,14 @@
 $title: title object related to the revision
 $rev: revision (object) that will be viewed
 
+'UnitTestsAfterDatabaseSetup': Called right after MediaWiki's test 
infrastructure
+has finished creating/duplicating core tables for unit tests.
+$database: Database in question
+$prefix: Table prefix to be used in unit tests
+
+'UnitTestsBeforeDatabaseTeardown': Called right before MediaWiki tears down its
+database infrastructure used for unit tests.
+
 'UnitTestsList': Called when building a list of paths containing PHPUnit tests.
 Since 1.24: Paths pointing to a directory will be recursively scanned for
 test case files matching the suffix "Test.php".
diff --git a/tests/phpunit/MediaWikiTestCase.php 
b/tests/phpunit/MediaWikiTestCase.php
index c1ada45..d804074 100644
--- a/tests/phpunit/MediaWikiTestCase.php
+++ b/tests/phpunit/MediaWikiTestCase.php
@@ -5,6 +5,8 @@
 use MediaWiki\Logger\MonologSpi;
 use MediaWiki\MediaWikiServices;
 use Psr\Log\LoggerInterface;
+use Wikimedia\Rdbms\IMaintainableDatabase;
+use Wikimedia\Rdbms\Database;
 use Wikimedia\TestingAccessWrapper;
 
 /**
@@ -1101,6 +1103,8 @@
return;
}
 
+   Hooks::run( 'UnitTestsBeforeDatabaseTeardown' );
+
foreach ( $wgJobClasses as $type => $class ) {
// Delete any jobs under the clone DB (or old prefix in 
other stores)
JobQueueGroup::singleton()->get( $type )->delete();
@@ -1203,6 +1207,8 @@
if ( $db->getType() == 'oracle' ) {
$db->query( 'BEGIN FILL_WIKI_INFO; END;' );
}
+
+   Hooks::run( 'UnitTestsAfterDatabaseSetup', [ $db, $prefix ] );
}
 
/**

-- 
To view, visit https://gerrit.wikimedia.org/r/363892
To unsubscribe, visit https://gerrit.wikimedia.org/r/settings

Gerrit-MessageType: newchange
Gerrit-Change-Id: If7050513719833d4167a24283885d7c10a25856b
Gerrit-PatchSet: 1
Gerrit-Project: mediawiki/core
Gerrit-Branch: wmf/1.30.0-wmf.7
Gerrit-Owner: Legoktm 
Gerrit-Reviewer: MaxSem 

___
MediaWiki-commits mailing list
MediaWiki-commits@lists.wikimedia.org
https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits