Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix random integration test failure due to timestamp roll over #224

Merged
merged 1 commit into from
Sep 27, 2023
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
31 changes: 17 additions & 14 deletions tests/Integration/QueueTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -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),
Expand Down Expand Up @@ -350,4 +346,11 @@ private function addRequestSetsToQueue($numRequestSets)
}
}

private function setTimestamps(array $array): array
{
foreach ($array as $request) {
$request->setCurrentTimestamp(1);
}
return $array;
}
}