Issue #3415769 by Spokje, smustgrave: Use random user IDs in tests only only when intended to

merge-requests/5425/head^2
catch 2024-01-25 10:24:37 +00:00
parent 40a4886362
commit b31bcec20d
4 changed files with 8 additions and 5 deletions

View File

@ -138,7 +138,7 @@ class ContentTranslationSyncImageTest extends ContentTranslationTestBase {
// Populate the test entity with some random initial values.
$values = [
'name' => $this->randomMachineName(),
'user_id' => mt_rand(1, 128),
'user_id' => 2,
'langcode' => $default_langcode,
];
$entity = \Drupal::entityTypeManager()

View File

@ -88,7 +88,7 @@ class SqlContentEntityStorageSchemaColumnTest extends KernelTestBase {
// Create an entity with field data.
$this->entity = EntityTestRev::create([
'user_id' => mt_rand(1, 10),
'user_id' => 2,
'name' => $this->randomMachineName(),
$field_name => $this->randomString(),
]);

View File

@ -158,7 +158,7 @@ class EntityTranslationTest extends EntityLanguageTestBase {
$langcode_key = $this->entityTypeManager->getDefinition($entity_type)->getKey('langcode');
$default_langcode_key = $this->entityTypeManager->getDefinition($entity_type)->getKey('default_langcode');
$name = $this->randomMachineName();
$uid = mt_rand(0, 127);
$uid = 2;
$langcode = $this->langcodes[0];
// Create a language neutral entity and check that properties are stored
@ -206,6 +206,8 @@ class EntityTranslationTest extends EntityLanguageTestBase {
if ($langcode != $default_langcode) {
$properties[$langcode] = [
'name' => [0 => $this->randomMachineName()],
// Note that the user ID here is intentionally random, which is not
// what we normally do in tests.
'user_id' => [0 => mt_rand(128, 256)],
];
}
@ -593,7 +595,7 @@ class EntityTranslationTest extends EntityLanguageTestBase {
$values = [];
foreach ($this->langcodes as $langcode) {
$values[$langcode]['name'] = $this->randomMachineName();
$values[$langcode]['user_id'] = mt_rand(0, 127);
$values[$langcode]['user_id'] = 2;
}
$default_langcode = $this->langcodes[0];

View File

@ -39,7 +39,8 @@ class TempStoreDatabaseTest extends KernelTestBase {
);
$collection = $this->randomMachineName();
// Create two mock users.
// Create two mock user IDs. Note that the user IDs are intentionally
// random, which is not what we normally do in tests.
for ($i = 0; $i <= 1; $i++) {
$users[$i] = mt_rand(500, 5000000);