Page MenuHomePhabricator

BetaFeatures unit tests failing after change to User::addGroup
Closed, DuplicatePublic

Description

73224f4f8b8a26b9a9a04e338bb1c3c2f163a820 changed User::addGroup to throw an exception if a group is added to a User object which is not stored in the database. Before that such calls succeeded without any DB change and while it's unclear if this was intentional (c95ec8d74e78599f26aaf70cc095bfcc29f49591 says "as paranoia, don't insert a groups record into the database if User::addGroup() ends up run on a non-existing user" so it's not exactly encouraged behavior), some tests did rely on it.

BetaFeatures tests, specifically, are failing:

23:10:44 1) AutoEnrollmentTest::testAutoEnroll with data set #0 (null, null, 'unittest-ft1', null, 'Hooks set the preference thou...t set.')
23:10:44 UnexpectedValueException: UserGroupMembership::insert() needs a positive user ID. Did you forget to add your User object to the database before calling addGroup()?
23:10:44 
23:10:44 /srv/jenkins-workspace/workspace/mwext-testextension-php55/src/includes/user/UserGroupMembership.php:196
23:10:44 /srv/jenkins-workspace/workspace/mwext-testextension-php55/src/includes/user/User.php:3395
23:10:44 /srv/jenkins-workspace/workspace/mwext-testextension-php55/src/extensions/BetaFeatures/tests/phpunit/BetaFeaturesTestCase.php:39
23:10:44 /srv/jenkins-workspace/workspace/mwext-testextension-php55/src/extensions/BetaFeatures/tests/phpunit/AutoEnrollmentTest.php:144
23:10:44 /srv/jenkins-workspace/workspace/mwext-testextension-php55/src/tests/phpunit/MediaWikiTestCase.php:400
23:10:44 /srv/jenkins-workspace/workspace/mwext-testextension-php55/src/maintenance/doMaintenance.php:111
23:10:44 
23:10:44 2) AutoEnrollmentTest::testAutoEnroll with data set #1 ('betafeatures-auto-enroll', '1', 'unittest-ft1', '1', 'Hooks did not set the prefere...s set.')
23:10:44 UnexpectedValueException: UserGroupMembership::insert() needs a positive user ID. Did you forget to add your User object to the database before calling addGroup()?
23:10:44 
23:10:44 /srv/jenkins-workspace/workspace/mwex

Event Timeline

Restricted Application added a subscriber: Aklapper. · View Herald TranscriptJan 27 2017, 11:34 PM
Tgr renamed this task from BetaFeatures unit tests failing (AutoEnroll) and blocking merges to BetaFeatures unit tests failing after change to User::addGroup.Jan 27 2017, 11:48 PM
Tgr updated the task description. (Show Details)