use MediaWikiCoversValidator;
use PHPUnit4And6Compat;
+ use MediaWikiGroupValidator;
/**
* The original service locator. This is overridden during setUp().
public static function setUpBeforeClass() {
parent::setUpBeforeClass();
- \PHPUnit\Framework\Assert::assertFileExists( 'LocalSettings.php' );
self::initializeForStandardPhpunitEntrypointIfNeeded();
// Get the original service locator
}
/**
+ * 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
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.
*