jenkins-bot has submitted this change and it was merged.
Change subject: UserTest: Fix edit count test which incorrectly added user to db
......................................................................
UserTest: Fix edit count test which incorrectly added user to db
Although 'added' to the database, the user name was cleared
in User::loadDefaults() and not added correctly to the database.
Then if one has BetaFeatures extension, then the test fails.
Via a hook, BetaFeatures does "User::newFromName( $user->getName() );",
that produces a null object as name is '127.0.0.1' and then
$user->getOption() fails.
loadDefaults() is automatically called by addToDatabase() with correct
parameters, so we can just remove the call.
Bug: 68626
Change-Id: Ibb5c60192eb83b2608f72b59d7705854549a5dac
---
M tests/phpunit/includes/UserTest.php
1 file changed, 9 insertions(+), 4 deletions(-)
Approvals:
Hoo man: Looks good to me, approved
jenkins-bot: Verified
diff --git a/tests/phpunit/includes/UserTest.php
b/tests/phpunit/includes/UserTest.php
index 5be1b96..a0c20bb 100644
--- a/tests/phpunit/includes/UserTest.php
+++ b/tests/phpunit/includes/UserTest.php
@@ -214,8 +214,10 @@
*/
public function testEditCount() {
$user = User::newFromName( 'UnitTestUser' );
- $user->loadDefaults();
- $user->addToDatabase();
+
+ if ( !$user->getId() ) {
+ $user->addToDatabase();
+ }
// let the user have a few (3) edits
$page = WikiPage::factory( Title::newFromText(
'Help:UserTest_EditCount' ) );
@@ -248,7 +250,10 @@
*/
public function testOptions() {
$user = User::newFromName( 'UnitTestUser' );
- $user->addToDatabase();
+
+ if ( !$user->getId() ) {
+ $user->addToDatabase();
+ }
$user->setOption( 'userjs-someoption', 'test' );
$user->setOption( 'cols', 200 );
@@ -281,7 +286,7 @@
$wgPasswordExpireGrace = 3600 * 24 * 7; // 7 days
$user = User::newFromName( 'UnitTestUser' );
- $user->loadDefaults();
+ $user->loadDefaults( 'UnitTestUser' );
$this->assertEquals( false, $user->getPasswordExpired() );
$ts = time() - ( 3600 * 24 * 1 ); // 1 day ago
--
To view, visit https://gerrit.wikimedia.org/r/161670
To unsubscribe, visit https://gerrit.wikimedia.org/r/settings
Gerrit-MessageType: merged
Gerrit-Change-Id: Ibb5c60192eb83b2608f72b59d7705854549a5dac
Gerrit-PatchSet: 9
Gerrit-Project: mediawiki/core
Gerrit-Branch: master
Gerrit-Owner: Aude <[email protected]>
Gerrit-Reviewer: Addshore <[email protected]>
Gerrit-Reviewer: Bartosz DziewoĆski <[email protected]>
Gerrit-Reviewer: Daniel Kinzler <[email protected]>
Gerrit-Reviewer: Hoo man <[email protected]>
Gerrit-Reviewer: jenkins-bot <>
_______________________________________________
MediaWiki-commits mailing list
[email protected]
https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits