I installed a fresh copy of MediaWiki twice, and called the two wikis enwiki and metawiki. Using the LocalSettings.php file for each wiki, phpunit.php would pass without any errors or failures.
Then I ran the maintenance scripts in CentralAuth to migrate the accounts, and used this LocalSettings.php file: P6911
Now phpunit.php does not even complete. At around 49% it crashes with the following exception:
[38b60820dc74538bf26fcc20] [no req] MWException from line 4194 of /var/www/html/includes/user/User.php: CAS update failed on user_touched for user ID '1' (read from master); the version of the user to be saved is older than the current version.
Backtrace:
#0 [internal function]: User->{closure}(Wikimedia\Rdbms\DatabaseMysqli, string)
#1 /var/www/html/includes/libs/rdbms/database/Database.php(3369): call_user_func_array(Closure, array)
#2 /var/www/html/includes/user/User.php(4208): Wikimedia\Rdbms\Database->doAtomicSection(string, Closure)
#3 /var/www/html/tests/phpunit/includes/TestUser.php(81): User->saveSettings()
#4 /var/www/html/tests/phpunit/includes/TestUserRegistry.php(87): TestUser->__construct(string, string, string, array, string)
#5 /var/www/html/tests/phpunit/MediaWikiTestCase.php(153): TestUserRegistry::getImmutableTestUser(array)
#6 /var/www/html/tests/phpunit/MediaWikiTestCase.php(177): MediaWikiTestCase::getTestUser(array)
#7 /var/www/html/tests/phpunit/MediaWikiTestCase.php(1087): MediaWikiTestCase::getTestSysop()
#8 /var/www/html/tests/phpunit/MediaWikiTestCase.php(1474): MediaWikiTestCase->addCoreDBData()
#9 /var/www/html/tests/phpunit/MediaWikiTestCase.php(423): MediaWikiTestCase->resetDB(Wikimedia\Rdbms\DatabaseMysqli, array)
#10 /var/www/html/vendor/phpunit/phpunit/src/Framework/TestSuite.php(722): MediaWikiTestCase->run(PHPUnit_Framework_TestResult)
#11 /var/www/html/vendor/phpunit/phpunit/src/Framework/TestSuite.php(722): PHPUnit_Framework_TestSuite->run(PHPUnit_Framework_TestResult)
#12 /var/www/html/vendor/phpunit/phpunit/src/Framework/TestSuite.php(722): PHPUnit_Framework_TestSuite->run(PHPUnit_Framework_TestResult)
#13 /var/www/html/vendor/phpunit/phpunit/src/TextUI/TestRunner.php(440): PHPUnit_Framework_TestSuite->run(PHPUnit_Framework_TestResult)
#14 /var/www/html/vendor/phpunit/phpunit/src/TextUI/Command.php(149): PHPUnit_TextUI_TestRunner->doRun(PHPUnit_Framework_TestSuite, array)
#15 /var/www/html/vendor/phpunit/phpunit/src/TextUI/Command.php(100): PHPUnit_TextUI_Command->run(array, boolean)
#16 /var/www/html/tests/phpunit/phpunit.php(134): PHPUnit_TextUI_Command::main()
#17 /var/www/html/maintenance/doMaintenance.php(94): PHPUnitMaintClass->execute()
#18 /var/www/html/tests/phpunit/phpunit.php(173): require(string)
#19 {main}Running phpunit.php with the --tap option shows the failure happens at this point:
...
ok 8860 - Pbkdf2PasswordTest::testCrypt with data set #0 ('pbkdf2')
ok 8861 - Pbkdf2PasswordTest::testMediaWikiTestCaseParentSetupCalled
ok 8862 - Pbkdf2PasswordTest::testValidCovers
ok 8863 - UserPasswordPolicyTest::testGetPoliciesForUser
[ced4dc722a6ad570c4e67133] [no req] MWException from line 4194 of /var/www/html/includes/user/User.php: CAS update failed on user_touched for user ID '1' (read from master); the version of the user to be saved is older than the current version.
...