Skip to content

Commit

Permalink
Added php_unit_strict to php-cs-fixer config
Browse files Browse the repository at this point in the history
  • Loading branch information
aivchen committed Jan 22, 2024
1 parent d49d322 commit 9dc6cb7
Show file tree
Hide file tree
Showing 36 changed files with 193 additions and 193 deletions.
1 change: 1 addition & 0 deletions .php-cs-fixer.dist.php
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@
'void_return' => true,
'native_function_invocation' => ['include' => ['@compiler_optimized'], 'scope' => 'namespaced'],
'php_unit_test_case_static_method_calls' => ['call_type' => 'self'],
'php_unit_strict' => true,
];

$config = new PhpCsFixer\Config();
Expand Down
10 changes: 5 additions & 5 deletions tests/Contracts/CancelTasksQueryTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -13,24 +13,24 @@ public function testSetTypes(): void
{
$data = (new CancelTasksQuery())->setTypes(['abc', 'xyz']);

self::assertEquals(['types' => 'abc,xyz'], $data->toArray());
self::assertSame(['types' => 'abc,xyz'], $data->toArray());
}

public function testSetAnyDateFilter(): void
{
$date = new \DateTime();
$data = (new CancelTasksQuery())->setBeforeEnqueuedAt($date);

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

public function testToArrayWithDifferentSets(): void
{
$data = (new CancelTasksQuery())->setUids([1, 2, 3])->setStatuses(['enqueued']);

self::assertEquals([
'uids' => '1,2,3', 'statuses' => 'enqueued',
],
self::assertSame([
'statuses' => 'enqueued', 'uids' => '1,2,3',
],
$data->toArray()
);
}
Expand Down
8 changes: 4 additions & 4 deletions tests/Contracts/DeleteTasksQueryTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -13,23 +13,23 @@ public function testSetTypes(): void
{
$data = (new DeleteTasksQuery())->setTypes(['abc', 'xyz']);

self::assertEquals(['types' => 'abc,xyz'], $data->toArray());
self::assertSame(['types' => 'abc,xyz'], $data->toArray());
}

public function testSetAnyDateFilter(): void
{
$date = new \DateTime();
$data = (new DeleteTasksQuery())->setCanceledBy([null])->setBeforeEnqueuedAt($date);

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

public function testToArrayWithDifferentSets(): void
{
$data = (new DeleteTasksQuery())->setCanceledBy([1, 2])->setStatuses(['enqueued']);

self::assertEquals([
'canceledBy' => '1,2', 'statuses' => 'enqueued',
self::assertSame([
'statuses' => 'enqueued', 'canceledBy' => '1,2',
], $data->toArray()
);
}
Expand Down
8 changes: 4 additions & 4 deletions tests/Contracts/DocumentsQueryTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -13,27 +13,27 @@ public function testSetFields(): void
{
$data = (new DocumentsQuery())->setLimit(10)->setFields(['abc', 'xyz']);

self::assertEquals(['limit' => 10, 'fields' => 'abc,xyz'], $data->toArray());
self::assertSame(['limit' => 10, 'fields' => 'abc,xyz'], $data->toArray());
}

public function testToArrayWithoutSetFields(): void
{
$data = (new DocumentsQuery())->setLimit(10);

self::assertEquals(['limit' => 10], $data->toArray());
self::assertSame(['limit' => 10], $data->toArray());
}

public function testToArrayWithoutSetOffset(): void
{
$data = (new DocumentsQuery())->setOffset(10);

self::assertEquals(['offset' => 10], $data->toArray());
self::assertSame(['offset' => 10], $data->toArray());
}

public function testToArrayWithZeros(): void
{
$data = (new DocumentsQuery())->setLimit(0)->setOffset(0);

self::assertEquals(['limit' => 0, 'offset' => 0], $data->toArray());
self::assertSame(['offset' => 0, 'limit' => 0], $data->toArray());
}
}
6 changes: 3 additions & 3 deletions tests/Contracts/IndexesQueryTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -13,14 +13,14 @@ public function testToArrayWithSetOffsetAndSetLimit(): void
{
$data = (new IndexesQuery())->setLimit(10)->setOffset(18);

self::assertEquals(['limit' => 10, 'offset' => 18], $data->toArray());
self::assertSame(['offset' => 18, 'limit' => 10], $data->toArray());
}

public function testToArrayWithSetOffset(): void
{
$data = (new IndexesQuery())->setOffset(5);

self::assertEquals(['offset' => 5], $data->toArray());
self::assertSame(['offset' => 5], $data->toArray());
}

public function testToArrayWithoutSet(): void
Expand All @@ -34,6 +34,6 @@ public function testToArrayWithZeros(): void
{
$data = (new IndexesQuery())->setLimit(0)->setOffset(0);

self::assertEquals(['limit' => 0, 'offset' => 0], $data->toArray());
self::assertSame(['offset' => 0, 'limit' => 0], $data->toArray());
}
}
6 changes: 3 additions & 3 deletions tests/Contracts/KeysQueryTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -13,14 +13,14 @@ public function testToArrayWithSetOffsetAndSetLimit(): void
{
$data = (new KeysQuery())->setLimit(10)->setOffset(18);

self::assertEquals(['limit' => 10, 'offset' => 18], $data->toArray());
self::assertSame(['offset' => 18, 'limit' => 10], $data->toArray());
}

public function testToArrayWithSetOffset(): void
{
$data = (new KeysQuery())->setOffset(5);

self::assertEquals(['offset' => 5], $data->toArray());
self::assertSame(['offset' => 5], $data->toArray());
}

public function testToArrayWithoutSet(): void
Expand All @@ -34,6 +34,6 @@ public function testToArrayWithZeros(): void
{
$data = (new KeysQuery())->setLimit(0)->setOffset(0);

self::assertEquals(['limit' => 0, 'offset' => 0], $data->toArray());
self::assertSame(['offset' => 0, 'limit' => 0], $data->toArray());
}
}
12 changes: 6 additions & 6 deletions tests/Contracts/TasksQueryTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -13,37 +13,37 @@ public function testSetTypes(): void
{
$data = (new TasksQuery())->setTypes(['abc', 'xyz']);

self::assertEquals(['types' => 'abc,xyz'], $data->toArray());
self::assertSame(['types' => 'abc,xyz'], $data->toArray());
}

public function testSetAnyDateFilter(): void
{
$date = new \DateTime();
$data = (new TasksQuery())->setBeforeEnqueuedAt($date);

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

public function testToArrayWithSetLimit(): void
{
$data = (new TasksQuery())->setLimit(10);

self::assertEquals(['limit' => 10], $data->toArray());
self::assertSame(['limit' => 10], $data->toArray());
}

public function testToArrayWithSetLimitWithZero(): void
{
$data = (new TasksQuery())->setLimit(0);

self::assertEquals(['limit' => 0], $data->toArray());
self::assertSame(['limit' => 0], $data->toArray());
}

public function testToArrayWithDifferentSets(): void
{
$data = (new TasksQuery())->setFrom(10)->setLimit(9)->setCanceledBy([1, 4])->setStatuses(['enqueued']);

self::assertEquals([
'limit' => 9, 'from' => 10, 'statuses' => 'enqueued', 'canceledBy' => '1,4',
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 @@ -184,7 +184,7 @@ public function testHealth(): void
{
$response = $this->client->health();

self::assertEquals('available', $response['status']);
self::assertSame('available', $response['status']);
}

public function testIsHealthyIsTrue(): void
Expand Down Expand Up @@ -233,7 +233,7 @@ public function testHeaderWithoutApiKey(): void

$response = $client->health();

self::assertEquals('available', $response['status']);
self::assertSame('available', $response['status']);
$this->expectException(ApiException::class);
$response = $client->stats();
}
Expand Down
43 changes: 21 additions & 22 deletions tests/Endpoints/DocumentsTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -81,8 +81,8 @@ public function testAddDocumentsCsv(): void

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

self::assertEquals('succeeded', $update['status']);
self::assertNotEquals(0, $update['details']['receivedDocuments']);
self::assertSame('succeeded', $update['status']);
self::assertNotSame(0, $update['details']['receivedDocuments']);

$response = $index->getDocuments();
self::assertCount(20, $response);
Expand All @@ -100,12 +100,12 @@ public function testAddDocumentsCsvWithCustomSeparator(): void

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

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

$documents = $index->getDocuments()->getResults();
self::assertEquals('Teenage Neon Jungle', $documents[4]['album']);
self::assertEquals('631152000', $documents[5]['released-timestamp']);
self::assertSame('Teenage Neon Jungle', $documents[4]['album']);
self::assertSame('631152000', $documents[5]['released-timestamp']);
}

public function testAddDocumentsJson(): void
Expand All @@ -122,8 +122,8 @@ public function testAddDocumentsJson(): void

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

self::assertEquals('succeeded', $update['status']);
self::assertNotEquals(0, $update['details']['receivedDocuments']);
self::assertSame('succeeded', $update['status']);
self::assertNotSame(0, $update['details']['receivedDocuments']);

$response = $index->getDocuments();
self::assertCount(20, $response);
Expand All @@ -143,8 +143,8 @@ public function testAddDocumentsNdJson(): void

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

self::assertEquals('succeeded', $update['status']);
self::assertNotEquals(0, $update['details']['receivedDocuments']);
self::assertSame('succeeded', $update['status']);
self::assertNotSame(0, $update['details']['receivedDocuments']);

$response = $index->getDocuments();
self::assertCount(20, $response);
Expand Down Expand Up @@ -323,10 +323,10 @@ public function testAddDocumentsCsvInBatchesWithDelimiter(): void
// withConsecutive has no replacement https://github.com/sebastianbergmann/phpunit/issues/4026
switch (++$invocation) {
case 1:
static::assertSame(["id;title\n888221515;Young folks", null, ';'], [$documents, $primaryKey, $delimiter]);
self::assertSame(["id;title\n888221515;Young folks", null, ';'], [$documents, $primaryKey, $delimiter]);
break;
case 2:
static::assertSame(["id;title\n235115704;Mister Klein", null, ';'], [$documents, $primaryKey, $delimiter]);
self::assertSame(["id;title\n235115704;Mister Klein", null, ';'], [$documents, $primaryKey, $delimiter]);
break;
default:
self::fail();
Expand Down Expand Up @@ -607,7 +607,7 @@ public function testGetDocumentsWithFilterCorrectFieldFormat(): void
->setFilter(['id > 100'])
->toArray()['fields'];

self::assertEquals($fields, $queryFields);
self::assertSame($fields, $queryFields);
}

public function testGetDocumentsWithoutFilterCorrectFieldsFormat(): void
Expand All @@ -618,7 +618,7 @@ public function testGetDocumentsWithoutFilterCorrectFieldsFormat(): void
->setFields($fields)
->toArray()['fields'];

self::assertEquals(
self::assertSame(
implode(',', $fields),
$queryFields
);
Expand Down Expand Up @@ -786,7 +786,6 @@ public function testUpdateDocumentsCsvInBatches(): void

public function testUpdateDocumentsCsvInBatchesWithDelimiter(): void
{
$matcher = self::atLeastOnce();
$replacement = 'id;title'.PHP_EOL;
$replacement .= '888221515;Young folks'.PHP_EOL;
$replacement .= '235115704;Mister Klein'.PHP_EOL;
Expand All @@ -797,22 +796,22 @@ public function testUpdateDocumentsCsvInBatchesWithDelimiter(): void
->disableOriginalConstructor()
->getMock();

$index->expects($matcher)
$index->expects(self::atLeastOnce())
->method('updateDocumentsCsv')
->willReturnCallback(function (string $param) use ($matcher): void {
->willReturnCallback(function (string $documents, $primaryKey, $delimiter): void {
static $invocation = 0;
// withConsecutive has no replacement https://github.com/sebastianbergmann/phpunit/issues/4026
switch ($matcher->numberOfInvocations()) {
switch (++$invocation) {
case 1:
self::assertEquals($param, ["id;title\n888221515;Young folks", null, ';']);
self::assertSame(["id;title\n888221515;Young folks", null, ';'], [$documents, $primaryKey, $delimiter]);
break;
case 2:
self::assertEquals($param, ["id;title\n235115704;Mister Klein", null, ';']);
self::assertSame(["id;title\n235115704;Mister Klein", null, ';'], [$documents, $primaryKey, $delimiter]);
break;
default:
self::fail();
}
})
->willReturn([], []);
});

$index->updateDocumentsCsvInBatches($replacement, 1, null, ';');
}
Expand Down
2 changes: 1 addition & 1 deletion tests/Endpoints/DumpTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,6 @@ public function testCreateDump(): void

$task = $this->client->createDump();

self::assertEquals($expectedKeys, array_keys($task));
self::assertSame($expectedKeys, array_keys($task));
}
}
2 changes: 1 addition & 1 deletion tests/Endpoints/IndexTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -128,7 +128,7 @@ public function testIndexStats(): void
$stats = $this->index->stats();

self::assertArrayHasKey('numberOfDocuments', $stats);
self::assertEquals(0, $stats['numberOfDocuments']);
self::assertSame(0, $stats['numberOfDocuments']);
self::assertArrayHasKey('isIndexing', $stats);
self::assertArrayHasKey('fieldDistribution', $stats);
}
Expand Down
4 changes: 2 additions & 2 deletions tests/Endpoints/KeysAndPermissionsTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@ public function testExceptionIfBadKeyProvidedToGetSettings(): void
$index = $this->safeIndexName();
$this->createEmptyIndex($index);
$response = $this->client->index($index)->getSettings();
self::assertEquals(['*'], $response['searchableAttributes']);
self::assertSame(['*'], $response['searchableAttributes']);

$newClient = new Client($this->host, 'bad-key');

Expand Down Expand Up @@ -231,7 +231,7 @@ public function testCreateKeyWithUid(): void
]);

self::assertNotNull($key->getKey());
self::assertEquals('acab6d06-5385-47a2-a534-1ed4fd7f6402', $key->getUid());
self::assertSame('acab6d06-5385-47a2-a534-1ed4fd7f6402', $key->getUid());

$this->client->deleteKey($key->getKey());
}
Expand Down
10 changes: 5 additions & 5 deletions tests/Endpoints/MultiSearchTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ public function testSearchQueryData(): void
{
$data = (new SearchQuery())->setIndexUid($this->booksIndex->getUid())->setQuery('butler')->setSort(['author:desc']);

self::assertEquals([
self::assertSame([
'indexUid' => $this->booksIndex->getUid(),
'q' => 'butler',
'sort' => ['author:desc'],
Expand Down Expand Up @@ -85,9 +85,9 @@ public function testSupportedQueryParams(): void

$result = $query->toArray();

self::assertEquals([1, 0.9, [0.9874]], $result['vector']);
self::assertEquals(['comment'], $result['attributesToSearchOn']);
self::assertEquals(true, $result['showRankingScore']);
self::assertEquals(true, $result['showRankingScoreDetails']);
self::assertSame([1, 0.9, [0.9874]], $result['vector']);
self::assertSame(['comment'], $result['attributesToSearchOn']);
self::assertTrue($result['showRankingScore']);
self::assertTrue($result['showRankingScoreDetails']);
}
}
Loading

0 comments on commit 9dc6cb7

Please sign in to comment.