From 528188f688cb739d46c4eab9f7beababa354aeef Mon Sep 17 00:00:00 2001 From: Pieter Frenssen Date: Sun, 12 May 2019 14:07:46 +0200 Subject: [PATCH] Fix random failure in OgMembershipTest::testGetSetCreatedTime(). CreatedItem::applyDefaultValue() is responsible for setting the created time on a newly created entity but still depends on the deprecated REQUEST_TIME constant. Switch back to this to avoid random failures when the time service is instantiated one second after the request time is set. --- tests/src/Kernel/Entity/OgMembershipTest.php | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/tests/src/Kernel/Entity/OgMembershipTest.php b/tests/src/Kernel/Entity/OgMembershipTest.php index b5ab37702..05c234c6f 100644 --- a/tests/src/Kernel/Entity/OgMembershipTest.php +++ b/tests/src/Kernel/Entity/OgMembershipTest.php @@ -585,7 +585,8 @@ public function testGetGroupIdOnNewMembership() { public function testGetSetCreatedTime() { // When creating a brand new membership the request time should be set as // the creation time. - $expected_time = $this->container->get('datetime.time')->getRequestTime(); + // @todo Replace this with \Drupal::time()->getRequestTime() in Drupal 9. + $expected_time = (int) $_SERVER['REQUEST_TIME']; $membership = OgMembership::create(); $this->assertEquals($expected_time, $membership->getCreatedTime());