Skip to content
Merged
Show file tree
Hide file tree
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
37 changes: 18 additions & 19 deletions tests/Endpoints/DocumentsTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -19,8 +19,7 @@ public function testAddDocuments(): void
$this->assertIsValidPromise($promise);

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

$response = $index->getDocuments();
$response = $index->getDocuments()['results'];
$this->assertCount(\count(self::DOCUMENTS), $response);
}

Expand All @@ -36,7 +35,7 @@ public function testAddDocumentsInBatches(): void
$index->waitForTask($promise['taskUid']);
}

$response = $index->getDocuments();
$response = $index->getDocuments()['results'];
$this->assertCount(\count(self::DOCUMENTS), $response);
}

Expand All @@ -54,7 +53,7 @@ public function testAddDocumentWithSpecialChars(): void
$this->assertIsValidPromise($promise);
$index->waitForTask($promise['taskUid']);

$response = $index->getDocuments();
$response = $index->getDocuments()['results'];
$this->assertCount(\count($documents), $response);

foreach ($documents as $k => $document) {
Expand All @@ -80,7 +79,7 @@ public function testAddDocumentsCsv(): void
$this->assertEquals($update['status'], 'succeeded');
$this->assertNotEquals($update['details']['receivedDocuments'], 0);

$response = $index->getDocuments();
$response = $index->getDocuments()['results'];
$this->assertCount(20, $response);
}

Expand All @@ -101,7 +100,7 @@ public function testAddDocumentsJson(): void
$this->assertEquals($update['status'], 'succeeded');
$this->assertNotEquals($update['details']['receivedDocuments'], 0);

$response = $index->getDocuments();
$response = $index->getDocuments()['results'];
$this->assertCount(20, $response);
}

Expand All @@ -122,7 +121,7 @@ public function testAddDocumentsNdJson(): void
$this->assertEquals($update['status'], 'succeeded');
$this->assertNotEquals($update['details']['receivedDocuments'], 0);

$response = $index->getDocuments();
$response = $index->getDocuments()['results'];
$this->assertCount(20, $response);
}

Expand Down Expand Up @@ -181,7 +180,7 @@ public function testReplaceDocuments(): void
$this->assertSame($replacement['id'], $response['id']);
$this->assertSame($replacement['title'], $response['title']);
$this->assertFalse(array_search('comment', $response, true));
$response = $index->getDocuments();
$response = $index->getDocuments()['results'];
$this->assertCount(\count(self::DOCUMENTS), $response);
}

Expand All @@ -205,7 +204,7 @@ public function testUpdateDocuments(): void
$this->assertSame($replacement['title'], $response['title']);
$this->assertArrayHasKey('comment', $response);

$response = $index->getDocuments();
$response = $index->getDocuments()['results'];

$this->assertCount(\count(self::DOCUMENTS), $response);
}
Expand Down Expand Up @@ -239,7 +238,7 @@ public function testUpdateDocumentsInBatches(): void
$this->assertArrayHasKey('comment', $response);
}

$response = $index->getDocuments();
$response = $index->getDocuments()['results'];
$this->assertCount(\count(self::DOCUMENTS), $response);
}

Expand All @@ -263,7 +262,7 @@ public function testAddWithUpdateDocuments(): void
$this->assertSame($document['title'], $response['title']);
$this->assertFalse(array_search('comment', $response, true));

$response = $index->getDocuments();
$response = $index->getDocuments()['results'];

$this->assertCount(\count(self::DOCUMENTS) + 1, $response);
}
Expand All @@ -280,7 +279,7 @@ public function testDeleteNonExistingDocument(): void
$this->assertIsValidPromise($promise);

$index->waitForTask($promise['taskUid']);
$response = $index->getDocuments();
$response = $index->getDocuments()['results'];

$this->assertCount(\count(self::DOCUMENTS), $response);
$this->assertNull($this->findDocumentWithId($response, $documentId));
Expand All @@ -298,7 +297,7 @@ public function testDeleteSingleExistingDocumentWithDocumentIdAsInteger(): void
$this->assertIsValidPromise($promise);

$index->waitForTask($promise['taskUid']);
$response = $index->getDocuments();
$response = $index->getDocuments()['results'];

$this->assertCount(\count(self::DOCUMENTS) - 1, $response);
$this->assertNull($this->findDocumentWithId($response, $documentId));
Expand All @@ -314,7 +313,7 @@ public function testDeleteSingleExistingDocumentWithDocumentIdAsString(): void
$promise = $index->deleteDocument($stringDocumentId);
$index->waitForTask($promise['taskUid']);

$response = $index->getDocuments();
$response = $index->getDocuments()['results'];

$this->assertEmpty($response);
}
Expand All @@ -330,7 +329,7 @@ public function testDeleteMultipleDocumentsWithDocumentIdAsInteger(): void
$this->assertIsValidPromise($promise);

$index->waitForTask($promise['taskUid']);
$response = $index->getDocuments();
$response = $index->getDocuments()['results'];

$this->assertCount(\count(self::DOCUMENTS) - 2, $response);
$this->assertNull($this->findDocumentWithId($response, $documentIds[0]));
Expand All @@ -351,7 +350,7 @@ public function testDeleteMultipleDocumentsWithDocumentIdAsString(): void
$promise = $index->deleteDocuments(['myUniqueId1', 'myUniqueId3']);
$index->waitForTask($promise['taskUid']);

$response = $index->getDocuments();
$response = $index->getDocuments()['results'];
$this->assertCount(1, $response);
$this->assertSame([['id' => 'myUniqueId2']], $response);
}
Expand All @@ -366,7 +365,7 @@ public function testDeleteAllDocuments(): void
$this->assertIsValidPromise($promise);

$index->waitForTask($promise['taskUid']);
$response = $index->getDocuments();
$response = $index->getDocuments()['results'];

$this->assertCount(0, $response);
}
Expand Down Expand Up @@ -396,7 +395,7 @@ public function testAddDocumentWithPrimaryKey(): void
$index->waitForTask($response['taskUid']);

$this->assertSame('unique', $index->fetchPrimaryKey());
$this->assertCount(1, $index->getDocuments());
$this->assertCount(1, $index->getDocuments()['results']);
}

public function testUpdateDocumentWithPrimaryKey(): void
Expand All @@ -416,7 +415,7 @@ public function testUpdateDocumentWithPrimaryKey(): void
$index->waitForTask($promise['taskUid']);

$this->assertSame('unique', $index->fetchPrimaryKey());
$this->assertCount(1, $index->getDocuments());
$this->assertCount(1, $index->getDocuments()['results']);
}

/**
Expand Down
6 changes: 3 additions & 3 deletions tests/Endpoints/TasksTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ public function testGetOneTaskFromWaitTask(): void
$this->assertArrayHasKey('status', $response);
$this->assertSame($response['uid'], $promise['taskUid']);
$this->assertArrayHasKey('type', $response);
$this->assertSame($response['type'], 'documentPartial');
$this->assertSame($response['type'], 'documentAdditionOrUpdate');
$this->assertArrayHasKey('indexUid', $response);
$this->assertSame($response['indexUid'], 'index');
$this->assertArrayHasKey('enqueuedAt', $response);
Expand All @@ -44,7 +44,7 @@ public function testGetOneTaskClient(): void
$this->assertArrayHasKey('status', $response);
$this->assertSame($response['uid'], $promise['taskUid']);
$this->assertArrayHasKey('type', $response);
$this->assertSame($response['type'], 'documentPartial');
$this->assertSame($response['type'], 'documentAdditionOrUpdate');
$this->assertArrayHasKey('indexUid', $response);
$this->assertSame($response['indexUid'], 'index');
$this->assertArrayHasKey('enqueuedAt', $response);
Expand Down Expand Up @@ -74,7 +74,7 @@ public function testGetOneTaskIndex(): void
$this->assertArrayHasKey('status', $response);
$this->assertSame($response['uid'], $promise['taskUid']);
$this->assertArrayHasKey('type', $response);
$this->assertSame($response['type'], 'documentPartial');
$this->assertSame($response['type'], 'documentAdditionOrUpdate');
$this->assertArrayHasKey('indexUid', $response);
$this->assertSame($response['indexUid'], 'index');
$this->assertArrayHasKey('enqueuedAt', $response);
Expand Down