- protected function getTestLock() {
- // Ensure that the generated lock ID is not in use, which may happen when
- // tests are run concurrently.
+ protected function getTestLock($create_lock = FALSE) {
+ // There is a risk that the generated random number is a duplicate. This
+ // would cause different tests to try to use the same database prefix.
+ // Therefore, if running with a concurrency of greater than 1, we need to
+ // create a lock.
+ if (getenv('RUN_TESTS_CONCURRENCY') > 1) {
+ $create_lock = TRUE;
+ }
+