Attempt to fix a flaky integration test

This commit attempts to fix the integration test
SubscriberListingRepositoryTest::testReturnsCorrectCountForSubscribersInDynamicSegment()
that was failing sometimes on CircleCI. My theory is that the test was
failing because we were using created_at to order the subscribers in the
query that is used to get subscribers in a given dynamic segment, but
there is a chance the the value of this field is the same for all the
three subscribers that are created in this test. As this could lead to a
situation where the order of the returned subscribers changes, causing
the test to fail. To work around that, I changed the test to order the
results by ID. This way we should always get the subscribers in the same
order.

[MAILPOET-3451]
This commit is contained in:
Rodrigo Primo
2021-03-12 13:50:03 -03:00
committed by Veljko V
parent deb4d7833d
commit a49bf8118a

View File

@@ -212,6 +212,7 @@ class SubscriberListingRepositoryTest extends \MailPoetTest {
$this->listingData['filter'] = ['segment' => $list->getId()];
$this->listingData['limit'] = 2;
$this->listingData['offset'] = 2;
$this->listingData['sort_by'] = 'id';
$data = $this->repository->getData($this->getListingDefinition());
expect(count($data))->equals(1);
expect($data[0]->getEmail())->equals($wpUserEmail3);