X-Git-Url: https://git.heureux-cyclage.org/?p=lhc%2Fweb%2Fwiklou.git;a=blobdiff_plain;f=tests%2Fphpunit%2FMediaWikiIntegrationTestCase.php;h=536de246809885b7eab2a554f776bff895a9dfc4;hp=999ba47a427ec9f10a757c5c5454904fdf36cbd2;hb=6568edb9e2e6b3988d8355360fa891ddf06fbdfa;hpb=52ea095f2c0b874939dc6489a7143f03717b30eb diff --git a/tests/phpunit/MediaWikiIntegrationTestCase.php b/tests/phpunit/MediaWikiIntegrationTestCase.php index 999ba47a42..536de24680 100644 --- a/tests/phpunit/MediaWikiIntegrationTestCase.php +++ b/tests/phpunit/MediaWikiIntegrationTestCase.php @@ -24,6 +24,7 @@ abstract class MediaWikiIntegrationTestCase extends PHPUnit\Framework\TestCase { use MediaWikiCoversValidator; use PHPUnit4And6Compat; + use MediaWikiGroupValidator; /** * The original service locator. This is overridden during setUp(). @@ -180,7 +181,6 @@ abstract class MediaWikiIntegrationTestCase extends PHPUnit\Framework\TestCase { public static function setUpBeforeClass() { parent::setUpBeforeClass(); - \PHPUnit\Framework\Assert::assertFileExists( 'LocalSettings.php' ); self::initializeForStandardPhpunitEntrypointIfNeeded(); // Get the original service locator @@ -1220,8 +1220,23 @@ abstract class MediaWikiIntegrationTestCase extends PHPUnit\Framework\TestCase { } /** + * Overrides specific user permissions until services are reloaded * * @since 1.34 + * + * @param User $user + * @param string[]|string $permissions + * + * @throws Exception + */ + public function overrideUserPermissions( $user, $permissions = [] ) { + MediaWikiServices::getInstance()->getPermissionManager()->overrideUserRightsForTesting( + $user, + $permissions + ); + } + + /** * Sets the logger for a specified channel, for the duration of the test. * @since 1.27 * @param string $channel @@ -1304,17 +1319,6 @@ abstract class MediaWikiIntegrationTestCase extends PHPUnit\Framework\TestCase { return $this->tablesUsed || $this->isTestInDatabaseGroup(); } - /** - * @return bool - * @since 1.32 - */ - protected function isTestInDatabaseGroup() { - // If the test class says it belongs to the Database group, it needs the database. - // NOTE: This ONLY checks for the group in the class level doc comment. - $rc = new ReflectionClass( $this ); - return (bool)preg_match( '/@group +Database/im', $rc->getDocComment() ); - } - /** * Insert a new page. *