Issue #2857843 by vaplas, mpdonadio, Jo Fitzgerald, gambry: Random fail in Drupal\KernelTests\Core\Entity\ContentEntityChangedTest::testChanged
parent
a20201a5ab
commit
8265b7736c
|
@ -31,7 +31,14 @@ class ChangedTestItem extends ChangedItem {
|
||||||
// During a test the request time is immutable. To allow tests of the
|
// During a test the request time is immutable. To allow tests of the
|
||||||
// algorithm of
|
// algorithm of
|
||||||
// Drupal\Core\Field\Plugin\Field\FieldType\ChangedItem::preSave() we need
|
// 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();
|
$this->value = time();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue