From 451c4a02cc8e453cfe098d4a47842fc97831dad3 Mon Sep 17 00:00:00 2001 From: Marc Neudert Date: Wed, 27 Sep 2023 09:20:07 +0200 Subject: [PATCH] Fix random integration test failure due to timestamp roll over --- tests/Integration/QueueTest.php | 31 +++++++++++++++++-------------- 1 file changed, 17 insertions(+), 14 deletions(-) diff --git a/tests/Integration/QueueTest.php b/tests/Integration/QueueTest.php index 1aefb16..e476a09 100644 --- a/tests/Integration/QueueTest.php +++ b/tests/Integration/QueueTest.php @@ -79,27 +79,23 @@ public function test_internalBuildRequestsSet_ShouldReturnRequestObjects() $this->assertCount(10, $this->buildRequestSetWithIdSite(10)->getRequests()); } - private function setTimestamps(array $array): array - { - foreach ($array as $request) { - $request->setCurrentTimestamp(1); - } - return $array; - } - public function test_internalBuildRequestsSet_ShouldBeAbleToSpecifyTheSiteId() { - $this->assertEquals(array( - new Request(array('idsite' => 2)), - new Request(array('idsite' => 2)), - new Request(array('idsite' => 2)), - ), $this->buildRequestSetWithIdSite(3, 2)->getRequests()); + $expected = [ + new Request(['idsite' => 2]), + new Request(['idsite' => 2]), + new Request(['idsite' => 2]), + ]; + + $actual = $this->buildRequestSetWithIdSite(3, 2)->getRequests(); + + $this->assertEquals($this->setTimestamps($expected), $this->setTimestamps($actual)); } public function test_internalBuildManyRequestsContainingRequests_ShouldReturnManyRequestObjects() { $this->assertEquals(array(), $this->buildManyRequestSets(0)); - $this->assertEquals(array($this->buildRequestSetWithIdSite(1)), $this->buildManyRequestSets(1)); + $this->assertManyRequestSetsAreEqual(array($this->buildRequestSetWithIdSite(1)), $this->buildManyRequestSets(1)); $this->assertManyRequestSetsAreEqual(array( $this->buildRequestSetWithIdSite(1), @@ -350,4 +346,11 @@ private function addRequestSetsToQueue($numRequestSets) } } + private function setTimestamps(array $array): array + { + foreach ($array as $request) { + $request->setCurrentTimestamp(1); + } + return $array; + } }