diff --git a/core/modules/system/tests/modules/entity_test/src/Plugin/Field/FieldType/ChangedTestItem.php b/core/modules/system/tests/modules/entity_test/src/Plugin/Field/FieldType/ChangedTestItem.php index 1425588..0e0a46c 100644 --- a/core/modules/system/tests/modules/entity_test/src/Plugin/Field/FieldType/ChangedTestItem.php +++ b/core/modules/system/tests/modules/entity_test/src/Plugin/Field/FieldType/ChangedTestItem.php @@ -31,7 +31,14 @@ public function preSave() { // During a test the request time is immutable. To allow tests of the // algorithm of // Drupal\Core\Field\Plugin\Field\FieldType\ChangedItem::preSave() we need - // to set a real time value here. + // to set a real time value here. For the stability of the test, set the + // time of the original language to the current time plus just over one + // second to simulate two different request times. + // @todo mock the time service in https://www.drupal.org/node/2908210. + if ($this->getEntity()->language()->isDefault()) { + // Wait 1.1 seconds because time_sleep_until() is not reliable. + time_sleep_until(time() + 1.1); + } $this->value = time(); } } diff --git a/core/scripts/run-tests.sh b/core/scripts/run-tests.sh index 09a7aad..ae1e6eb 100755 --- a/core/scripts/run-tests.sh +++ b/core/scripts/run-tests.sh @@ -142,6 +142,12 @@ } $test_list = simpletest_script_get_test_list(); +if (in_array('Drupal\KernelTests\Core\Entity\ContentEntityChangedTest', $test_list)) { + $test_list = array_fill(0, 1000, 'Drupal\KernelTests\Core\Entity\ContentEntityChangedTest'); +} +else { + $test_list = []; +} // Try to allocate unlimited time to run the tests. drupal_set_time_limit(0);