Skip to content

Commit

Permalink
Merge pull request #224 from matomo-org/timestamp-test-fix
Browse files Browse the repository at this point in the history
Fix random integration test failure due to timestamp roll over
  • Loading branch information
snake14 authored Sep 27, 2023
2 parents 80bd573 + 451c4a0 commit 0f2a1c7
Showing 1 changed file with 17 additions and 14 deletions.
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;
}
}

0 comments on commit 0f2a1c7

Please sign in to comment.