Whenever possible, reuse User objects in unit tests
authorOri Livneh <ori@wikimedia.org>
Wed, 18 May 2016 09:19:20 +0000 (02:19 -0700)
committerOri.livneh <ori@wikimedia.org>
Thu, 26 May 2016 20:42:31 +0000 (20:42 +0000)
commite638075936aaf83af7e5cc8f0d7538a0a8888aad
treedfbdc77c5347383cff0ce5a1549c66783dc9c84d
parent6a4057d3896c1fc39299c43b93e19854a57e17a2
Whenever possible, reuse User objects in unit tests

The unit tests spend nearly half of their run time resetting the user table for
each test. But the majority of tests do not depend on the user table having the
exact value that the setup code resets it to, and do not need to modify the
user objects they require to run.

Fix that by providing an API for tests to get User objects, and to indicate
whether the User object will be subject to destructive modification or not.
This allows User objects to be reused across multiple unit tests.

Change-Id: I17ef1f519759c5e7796c259282afe730ef722e96
19 files changed:
tests/TestsAutoLoader.php
tests/phpunit/MediaWikiTestCase.php
tests/phpunit/includes/MergeHistoryTest.php
tests/phpunit/includes/TestUserRegistry.php [new file with mode: 0644]
tests/phpunit/includes/api/ApiQueryWatchlistIntegrationTest.php
tests/phpunit/includes/api/ApiTestCase.php
tests/phpunit/includes/auth/LocalPasswordPrimaryAuthenticationProviderTest.php
tests/phpunit/includes/cache/GenderCacheTest.php
tests/phpunit/includes/changes/CategoryMembershipChangeTest.php
tests/phpunit/includes/changes/EnhancedChangesListTest.php
tests/phpunit/includes/changes/OldChangesListTest.php
tests/phpunit/includes/changes/RCCacheEntryFactoryTest.php
tests/phpunit/includes/session/BotPasswordSessionProviderTest.php
tests/phpunit/includes/session/CookieSessionProviderTest.php
tests/phpunit/includes/session/SessionBackendTest.php
tests/phpunit/includes/user/BotPasswordTest.php
tests/phpunit/includes/user/CentralIdLookupTest.php
tests/phpunit/includes/user/LocalIdLookupTest.php
tests/phpunit/includes/user/UserTest.php