Skip to content

Commit

Permalink
Swap assertion parameters
Browse files Browse the repository at this point in the history
Co-authored-by: Tomas Norkūnas <[email protected]>
  • Loading branch information
aivchen and norkunas authored Jan 23, 2024
1 parent 9dc6cb7 commit da9a533
Show file tree
Hide file tree
Showing 7 changed files with 21 additions and 33 deletions.
6 changes: 1 addition & 5 deletions tests/Contracts/CancelTasksQueryTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -28,10 +28,6 @@ public function testToArrayWithDifferentSets(): void
{
$data = (new CancelTasksQuery())->setUids([1, 2, 3])->setStatuses(['enqueued']);

self::assertSame([
'statuses' => 'enqueued', 'uids' => '1,2,3',
],
$data->toArray()
);
self::assertSame(['statuses' => 'enqueued', 'uids' => '1,2,3'], $data->toArray());
}
}
5 changes: 1 addition & 4 deletions tests/Contracts/DeleteTasksQueryTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -28,9 +28,6 @@ public function testToArrayWithDifferentSets(): void
{
$data = (new DeleteTasksQuery())->setCanceledBy([1, 2])->setStatuses(['enqueued']);

self::assertSame([
'statuses' => 'enqueued', 'canceledBy' => '1,2',
], $data->toArray()
);
self::assertSame(['statuses' => 'enqueued', 'canceledBy' => '1,2'], $data->toArray());
}
}
6 changes: 2 additions & 4 deletions tests/Contracts/TasksQueryTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ public function testSetAnyDateFilter(): void
$date = new \DateTime();
$data = (new TasksQuery())->setBeforeEnqueuedAt($date);

self::assertSame($data->toArray(), ['beforeEnqueuedAt' => $date->format(\DateTime::RFC3339)]);
self::assertSame(['beforeEnqueuedAt' => $date->format(\DateTime::RFC3339)], $data->toArray());
}

public function testToArrayWithSetLimit(): void
Expand All @@ -42,8 +42,6 @@ public function testToArrayWithDifferentSets(): void
{
$data = (new TasksQuery())->setFrom(10)->setLimit(9)->setCanceledBy([1, 4])->setStatuses(['enqueued']);

self::assertSame([
'statuses' => 'enqueued', 'from' => 10, 'limit' => 9, 'canceledBy' => '1,4',
], $data->toArray());
self::assertSame(['statuses' => 'enqueued', 'from' => 10, 'limit' => 9, 'canceledBy' => '1,4'], $data->toArray());
}
}
4 changes: 2 additions & 2 deletions tests/Endpoints/ClientTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -120,8 +120,8 @@ public function testUpdateIndex(): void
$this->client->waitForTask($response['taskUid']);
$index = $this->client->getIndex($response['indexUid']);

self::assertSame($index->getPrimaryKey(), 'id');
self::assertSame($index->getUid(), $indexName);
self::assertSame('id', $index->getPrimaryKey());
self::assertSame($indexName, $index->getUid());
}

public function testDeleteIndex(): void
Expand Down
12 changes: 6 additions & 6 deletions tests/Endpoints/DocumentsTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -100,8 +100,8 @@ public function testAddDocumentsCsvWithCustomSeparator(): void

$update = $index->waitForTask($promise['taskUid']);

self::assertSame($update['status'], 'succeeded');
self::assertSame($update['details']['receivedDocuments'], 6);
self::assertSame('succeeded', $update['status']);
self::assertSame(6, $update['details']['receivedDocuments']);

$documents = $index->getDocuments()->getResults();
self::assertSame('Teenage Neon Jungle', $documents[4]['album']);
Expand Down Expand Up @@ -487,8 +487,8 @@ public function testMessageHintException(): void
} catch (\Exception $ex) {
$rethrowed = ApiException::rethrowWithHint($mockedException, 'deleteDocuments');

self::assertSame($ex->getPrevious()->getMessage(), 'Invalid response');
self::assertSame($ex->getMessage(), $rethrowed->getMessage());
self::assertSame('Invalid response', $ex->getPrevious()->getMessage());
self::assertSame($rethrowed->getMessage(), $ex->getMessage());
}
}

Expand Down Expand Up @@ -641,8 +641,8 @@ public function testGetDocumentsMessageHintException(): void
} catch (\Exception $ex) {
$rethrowed = ApiException::rethrowWithHint($mockedException, 'getDocuments');

self::assertSame($ex->getPrevious()->getMessage(), 'Invalid response');
self::assertSame($ex->getMessage(), $rethrowed->getMessage());
self::assertSame('Invalid response', $ex->getPrevious()->getMessage());
self::assertSame($rethrowed->getMessage(), $ex->getMessage());
}
}

Expand Down
6 changes: 2 additions & 4 deletions tests/Endpoints/FacetSearchTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -26,9 +26,7 @@ public function testBasicSearchWithFilters(): void
{
$response = $this->index->search('prince', ['facets' => ['genre']]);

self::assertSame(array_keys($response->getFacetDistribution()['genre']), [
'adventure', 'fantasy',
]);
self::assertSame(['adventure', 'fantasy'], array_keys($response->getFacetDistribution()['genre']));

$response = $this->index->facetSearch(
(new FacetSearchQuery())
Expand All @@ -37,6 +35,6 @@ public function testBasicSearchWithFilters(): void
->setQuery('prince')
);

self::assertSame(array_column($response->getFacetHits(), 'value'), ['fantasy']);
self::assertSame(['fantasy'], array_column($response->getFacetHits(), 'value'));
}
}
15 changes: 7 additions & 8 deletions tests/Endpoints/IndexTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -105,8 +105,8 @@ public function testFetchRawInfo(): void
self::assertArrayHasKey('uid', $response);
self::assertArrayHasKey('createdAt', $response);
self::assertArrayHasKey('updatedAt', $response);
self::assertSame($response['primaryKey'], 'objectId');
self::assertSame($response['uid'], $indexName);
self::assertSame('objectId', $response['primaryKey']);
self::assertSame($indexName, $response['uid']);
}

public function testPrimaryKeyUpdate(): void
Expand All @@ -117,10 +117,9 @@ public function testPrimaryKeyUpdate(): void
$this->client->waitForTask($response['taskUid']);
$index = $this->client->getIndex($response['indexUid']);

self::assertSame($index->getPrimaryKey(), $primaryKey);
self::assertSame($index->getUid(), $this->indexName);
self::assertSame($index->getPrimaryKey(), $primaryKey);
self::assertSame($this->index->getUid(), $this->indexName);
self::assertSame($primaryKey, $index->getPrimaryKey());
self::assertSame($this->indexName, $index->getUid());
self::assertSame($this->indexName, $this->index->getUid());
}

public function testIndexStats(): void
Expand Down Expand Up @@ -262,15 +261,15 @@ public function testSwapIndexes(): void
$promise = $this->client->swapIndexes([['indexA', 'indexB'], ['indexC', 'indexD']]);
$response = $this->client->waitForTask($promise['taskUid']);

self::assertSame($response['details']['swaps'], [['indexes' => ['indexA', 'indexB']], ['indexes' => ['indexC', 'indexD']]]);
self::assertSame([['indexes' => ['indexA', 'indexB']], ['indexes' => ['indexC', 'indexD']]], $response['details']['swaps']);
}

public function testDeleteTasks(): void
{
$promise = $this->client->deleteTasks((new DeleteTasksQuery())->setUids([1, 2]));
$response = $this->client->waitForTask($promise['taskUid']);

self::assertSame($response['details']['originalFilter'], '?uids=1%2C2');
self::assertSame('?uids=1%2C2', $response['details']['originalFilter']);
self::assertIsNumeric($response['details']['matchedTasks']);
}

Expand Down

0 comments on commit da9a533

Please sign in to comment.