Aaron Schulz has uploaded a new change for review. (
https://gerrit.wikimedia.org/r/353003 )
Change subject: Avoid assuming a user with ID 0 exists in
ApiMainTest::testAssert
......................................................................
Avoid assuming a user with ID 0 exists in ApiMainTest::testAssert
If the load() triggered by User method calls fails, then mId becomes 0
which means there is no "user" right set in getAutomaticGroups().
Bug: T75174
Change-Id: I2d719e4b96c0142e9d408aa2d4f7c5e7a767a754
---
M tests/phpunit/includes/api/ApiMainTest.php
1 file changed, 6 insertions(+), 3 deletions(-)
git pull ssh://gerrit.wikimedia.org:29418/mediawiki/core
refs/changes/03/353003/1
diff --git a/tests/phpunit/includes/api/ApiMainTest.php
b/tests/phpunit/includes/api/ApiMainTest.php
index 3e6ceb7..ea33a9e 100644
--- a/tests/phpunit/includes/api/ApiMainTest.php
+++ b/tests/phpunit/includes/api/ApiMainTest.php
@@ -45,9 +45,11 @@
* @param string|bool $error False if no error expected
*/
public function testAssert( $registered, $rights, $assert, $error ) {
- $user = new User();
if ( $registered ) {
- $user->setId( 1 );
+ $user = $this->getMutableTestUser()->getUser();
+ $user->load(); // load before setting mRights
+ } else {
+ $user = new User();
}
$user->mRights = $rights;
try {
@@ -57,7 +59,8 @@
], null, null, $user );
$this->assertFalse( $error ); // That no error was
expected
} catch ( ApiUsageException $e ) {
- $this->assertTrue( self::apiExceptionHasCode( $e,
$error ) );
+ $this->assertTrue( self::apiExceptionHasCode( $e,
$error ),
+ "Error '{$e->getMessage()}' matched expected
'$error'" );
}
}
--
To view, visit https://gerrit.wikimedia.org/r/353003
To unsubscribe, visit https://gerrit.wikimedia.org/r/settings
Gerrit-MessageType: newchange
Gerrit-Change-Id: I2d719e4b96c0142e9d408aa2d4f7c5e7a767a754
Gerrit-PatchSet: 1
Gerrit-Project: mediawiki/core
Gerrit-Branch: master
Gerrit-Owner: Aaron Schulz <[email protected]>
_______________________________________________
MediaWiki-commits mailing list
[email protected]
https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits