Skip to content

Commit 27da4a2

Browse files
committed
PS-3696 Functional test of sorting + pagination on Internal API client
1 parent 16d9432 commit 27da4a2

File tree

1 file changed

+36
-0
lines changed

1 file changed

+36
-0
lines changed

tests/ClientFunctionalTest.php

Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -571,6 +571,42 @@ public function testListJobsSort(): void
571571
self::assertSame($jobIds, $resIds);
572572
}
573573

574+
public function testListJobsSortMultipage(): void
575+
{
576+
$newJobFactory = $this->getNewJobFactory();
577+
$client = $this->getClient();
578+
579+
$jobs = array_map(fn () => $client->createJob($newJobFactory->createNewJob([
580+
'#tokenString' => getenv('TEST_STORAGE_API_TOKEN'),
581+
'configData' => [ ],
582+
'componentId' => self::COMPONENT_ID_1,
583+
'mode' => 'run',
584+
])), range(1, 10));
585+
586+
$jobIds = array_map(
587+
fn(JobInterface $job) => (int) $job->getId(),
588+
$jobs,
589+
);
590+
591+
$response = $client->listJobs(
592+
(new JobListOptions())
593+
->setIds($jobIds)
594+
->setSortBy('id')
595+
->setSortOrder(JobListOptions::SORT_ORDER_DESC)
596+
->setLimit(3),
597+
true
598+
);
599+
self::assertCount(10, $response);
600+
601+
rsort($jobIds);
602+
$resultJobIds = array_map(
603+
fn(JobInterface $job) => (int) $job->getId(),
604+
$response,
605+
);
606+
607+
self::assertSame($jobIds, $resultJobIds);
608+
}
609+
574610
public function testListJobsEscaping(): void
575611
{
576612
$newJobFactory = $this->getNewJobFactory();

0 commit comments

Comments
 (0)