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 flaky tasks reverse test #710

Merged
merged 4 commits into from
Dec 30, 2024
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
18 changes: 8 additions & 10 deletions tests/Endpoints/TasksTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -154,18 +154,16 @@ public function testCancelTasksWithFilter(): void

public function testGetAllTasksInReverseOrder(): void
{
$startDate = new \DateTimeImmutable('now');
$sampleTasks = $this->client->getTasks(new TasksQuery());
$sampleTasksUids = array_map(fn ($task) => $task['uid'], $sampleTasks->getResults());

$tasks = $this->client->getTasks((new TasksQuery())
->setAfterEnqueuedAt($startDate)
);
$reversedTasks = $this->client->getTasks((new TasksQuery())
->setAfterEnqueuedAt($startDate)
->setReverse(true)
);
$expectedTasks = $this->client->getTasks((new TasksQuery())->setUids($sampleTasksUids));
$expectedTasksUids = array_map(fn ($task) => $task['uid'], $expectedTasks->getResults());

$reversedTasks = $this->client->getTasks((new TasksQuery())->setUids($sampleTasksUids)->setReverse(true));
$reversedTasksUids = array_map(fn ($task) => $task['uid'], $reversedTasks->getResults());

self::assertSameSize($tasks->getResults(), $reversedTasks->getResults());
self::assertSame($tasks->getResults(), array_reverse($reversedTasks->getResults()));
self::assertSame(array_reverse($expectedTasksUids), $reversedTasksUids);
}

public function testExceptionIfNoTaskIdWhenGetting(): void
Expand Down
Loading