Skip to content

Commit 7b53b52

Browse files
committed
Rename $promise to $task in tests
1 parent f424477 commit 7b53b52

29 files changed

+271
-271
lines changed

tests/Endpoints/DocumentsTest.php

Lines changed: 82 additions & 82 deletions
Large diffs are not rendered by default.

tests/Endpoints/FacetSearchTest.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -18,8 +18,8 @@ protected function setUp(): void
1818

1919
$this->index = $this->createEmptyIndex($this->safeIndexName());
2020
$this->index->updateDocuments(self::DOCUMENTS);
21-
$promise = $this->index->updateFilterableAttributes(['genre']);
22-
$this->index->waitForTask($promise['taskUid']);
21+
$task = $this->index->updateFilterableAttributes(['genre']);
22+
$this->index->waitForTask($task['taskUid']);
2323
}
2424

2525
public function testBasicSearchWithFilters(): void

tests/Endpoints/IndexTest.php

Lines changed: 19 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -166,12 +166,12 @@ public function testGetAndFetchPrimaryKey(): void
166166

167167
public function testGetTasks(): void
168168
{
169-
$promise = $this->client->createIndex('new-index', ['primaryKey' => 'objectID']);
170-
$this->index->waitForTask($promise['taskUid']);
171-
$promise = $this->client->createIndex('other-index', ['primaryKey' => 'objectID']);
172-
$this->index->waitForTask($promise['taskUid']);
173-
$promise = $this->index->addDocuments([['id' => 1, 'title' => 'Pride and Prejudice']]);
174-
$this->index->waitForTask($promise['taskUid']);
169+
$task = $this->client->createIndex('new-index', ['primaryKey' => 'objectID']);
170+
$this->index->waitForTask($task['taskUid']);
171+
$task = $this->client->createIndex('other-index', ['primaryKey' => 'objectID']);
172+
$this->index->waitForTask($task['taskUid']);
173+
$task = $this->index->addDocuments([['id' => 1, 'title' => 'Pride and Prejudice']]);
174+
$this->index->waitForTask($task['taskUid']);
175175

176176
$tasks = $this->index->getTasks((new TasksQuery())->setIndexUids(['other-index']));
177177

@@ -184,12 +184,12 @@ public function testGetTasks(): void
184184

185185
public function testWaitForTaskDefault(): void
186186
{
187-
$promise = $this->index->addDocuments([['id' => 1, 'title' => 'Pride and Prejudice']]);
187+
$task = $this->index->addDocuments([['id' => 1, 'title' => 'Pride and Prejudice']]);
188188

189-
$response = $this->index->waitForTask($promise['taskUid']);
189+
$response = $this->index->waitForTask($task['taskUid']);
190190

191191
self::assertSame('succeeded', $response['status']);
192-
self::assertSame($response['uid'], $promise['taskUid']);
192+
self::assertSame($response['uid'], $task['taskUid']);
193193
self::assertArrayHasKey('type', $response);
194194
self::assertSame('documentAdditionOrUpdate', $response['type']);
195195
self::assertArrayHasKey('duration', $response);
@@ -199,11 +199,11 @@ public function testWaitForTaskDefault(): void
199199

200200
public function testWaitForTaskWithTimeoutAndInterval(): void
201201
{
202-
$promise = $this->index->addDocuments([['id' => 1, 'title' => 'Pride and Prejudice']]);
203-
$response = $this->index->waitForTask($promise['taskUid'], 100, 20);
202+
$task = $this->index->addDocuments([['id' => 1, 'title' => 'Pride and Prejudice']]);
203+
$response = $this->index->waitForTask($task['taskUid'], 100, 20);
204204

205205
self::assertSame('succeeded', $response['status']);
206-
self::assertSame($response['uid'], $promise['taskUid']);
206+
self::assertSame($response['uid'], $task['taskUid']);
207207
self::assertArrayHasKey('type', $response);
208208
self::assertSame('documentAdditionOrUpdate', $response['type']);
209209
self::assertArrayHasKey('duration', $response);
@@ -214,11 +214,11 @@ public function testWaitForTaskWithTimeoutAndInterval(): void
214214

215215
public function testWaitForTaskWithTimeout(): void
216216
{
217-
$promise = $this->index->addDocuments([['id' => 1, 'title' => 'Pride and Prejudice']]);
218-
$response = $this->index->waitForTask($promise['taskUid'], 1000);
217+
$task = $this->index->addDocuments([['id' => 1, 'title' => 'Pride and Prejudice']]);
218+
$response = $this->index->waitForTask($task['taskUid'], 1000);
219219

220220
self::assertSame('succeeded', $response['status']);
221-
self::assertSame($response['uid'], $promise['taskUid']);
221+
self::assertSame($response['uid'], $task['taskUid']);
222222
self::assertArrayHasKey('type', $response);
223223
self::assertSame('documentAdditionOrUpdate', $response['type']);
224224
self::assertArrayHasKey('duration', $response);
@@ -256,16 +256,16 @@ public function testDeleteIndexes(): void
256256

257257
public function testSwapIndexes(): void
258258
{
259-
$promise = $this->client->swapIndexes([['indexA', 'indexB'], ['indexC', 'indexD']]);
260-
$response = $this->client->waitForTask($promise['taskUid']);
259+
$task = $this->client->swapIndexes([['indexA', 'indexB'], ['indexC', 'indexD']]);
260+
$response = $this->client->waitForTask($task['taskUid']);
261261

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

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

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

tests/Endpoints/MultiSearchTest.php

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -21,17 +21,17 @@ protected function setUp(): void
2121
$this->booksIndex = $this->createEmptyIndex($this->safeIndexName('books'));
2222
$this->booksIndex->updateSortableAttributes(['author']);
2323
$this->booksIndex->updateFilterableAttributes(['genre']);
24-
$promise = $this->booksIndex->updateDocuments(self::DOCUMENTS);
25-
$this->booksIndex->waitForTask($promise['taskUid']);
24+
$task = $this->booksIndex->updateDocuments(self::DOCUMENTS);
25+
$this->booksIndex->waitForTask($task['taskUid']);
2626

2727
$this->songsIndex = $this->createEmptyIndex($this->safeIndexName('songs'));
2828
$this->songsIndex->updateFilterableAttributes(['duration-float']);
2929
$fileCsv = fopen('./tests/datasets/songs-custom-separator.csv', 'r');
3030
$documents = fread($fileCsv, filesize('./tests/datasets/songs-custom-separator.csv'));
3131
fclose($fileCsv);
3232

33-
$promise = $this->songsIndex->addDocumentsCsv($documents, null, '|');
34-
$this->songsIndex->waitForTask($promise['taskUid']);
33+
$task = $this->songsIndex->addDocumentsCsv($documents, null, '|');
34+
$this->songsIndex->waitForTask($task['taskUid']);
3535
}
3636

3737
public function testSearchQueryData(): void

tests/Endpoints/SearchNestedFieldsTest.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,8 +15,8 @@ protected function setUp(): void
1515
{
1616
parent::setUp();
1717
$this->index = $this->createEmptyIndex($this->safeIndexName('nestedIndex'));
18-
$promise = $this->index->updateDocuments(self::NESTED_DOCUMENTS);
19-
$this->index->waitForTask($promise['taskUid']);
18+
$task = $this->index->updateDocuments(self::NESTED_DOCUMENTS);
19+
$this->index->waitForTask($task['taskUid']);
2020
}
2121

2222
public function testBasicSearchOnNestedFields(): void

tests/Endpoints/SearchTest.php

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -17,8 +17,8 @@ protected function setUp(): void
1717
{
1818
parent::setUp();
1919
$this->index = $this->createEmptyIndex($this->safeIndexName());
20-
$promise = $this->index->updateDocuments(self::DOCUMENTS);
21-
$this->index->waitForTask($promise['taskUid']);
20+
$task = $this->index->updateDocuments(self::DOCUMENTS);
21+
$this->index->waitForTask($task['taskUid']);
2222
}
2323

2424
public function testBasicSearch(): void
@@ -709,11 +709,11 @@ public function testVectorSearch(): void
709709
{
710710
$index = $this->createEmptyIndex($this->safeIndexName());
711711

712-
$promise = $index->updateEmbedders(['manual' => ['source' => 'userProvided', 'dimensions' => 3]]);
713-
$index->waitForTask($promise['taskUid']);
712+
$task = $index->updateEmbedders(['manual' => ['source' => 'userProvided', 'dimensions' => 3]]);
713+
$index->waitForTask($task['taskUid']);
714714

715-
$promise = $index->updateDocuments(self::VECTOR_MOVIES);
716-
$index->waitForTask($promise['taskUid']);
715+
$task = $index->updateDocuments(self::VECTOR_MOVIES);
716+
$index->waitForTask($task['taskUid']);
717717

718718
$response = $index->search('', ['vector' => [-0.5, 0.3, 0.85], 'hybrid' => ['semanticRatio' => 1.0, 'embedder' => 'manual']]);
719719

@@ -866,8 +866,8 @@ public function testSearchAndRetrieveFacetStats(): void
866866
$this->index = $this->createEmptyIndex($this->safeIndexName());
867867
$this->index->updateFilterableAttributes(['info.reviewNb']);
868868

869-
$promise = $this->index->updateDocuments(self::NESTED_DOCUMENTS);
870-
$this->index->waitForTask($promise['taskUid']);
869+
$task = $this->index->updateDocuments(self::NESTED_DOCUMENTS);
870+
$this->index->waitForTask($task['taskUid']);
871871

872872
$response = $this->index->search(
873873
null,
@@ -882,8 +882,8 @@ public function testSearchWithDistinctAttribute(): void
882882
$this->index = $this->createEmptyIndex($this->safeIndexName());
883883
$this->index->updateFilterableAttributes(['genre']);
884884

885-
$promise = $this->index->updateDocuments(self::DOCUMENTS);
886-
$this->index->waitForTask($promise['taskUid']);
885+
$task = $this->index->updateDocuments(self::DOCUMENTS);
886+
$this->index->waitForTask($task['taskUid']);
887887

888888
$response = $this->index->search(null, [
889889
'distinct' => 'genre',
@@ -912,8 +912,8 @@ public function testSearchWithLocales(): void
912912
{
913913
$this->index = $this->createEmptyIndex($this->safeIndexName());
914914
$this->index->updateDocuments(self::DOCUMENTS);
915-
$promise = $this->index->updateLocalizedAttributes([['attributePatterns' => ['title', 'comment'], 'locales' => ['fra', 'eng']]]);
916-
$this->index->waitForTask($promise['taskUid']);
915+
$task = $this->index->updateLocalizedAttributes([['attributePatterns' => ['title', 'comment'], 'locales' => ['fra', 'eng']]]);
916+
$this->index->waitForTask($task['taskUid']);
917917

918918
$response = $this->index->search('french', [
919919
'locales' => ['fra', 'eng'],

tests/Endpoints/TasksTest.php

Lines changed: 16 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -24,10 +24,10 @@ protected function setUp(): void
2424

2525
public function testGetOneTaskFromWaitTask(): void
2626
{
27-
[$promise, $response] = $this->seedIndex();
27+
[$task, $response] = $this->seedIndex();
2828

2929
self::assertArrayHasKey('status', $response);
30-
self::assertSame($response['uid'], $promise['taskUid']);
30+
self::assertSame($response['uid'], $task['taskUid']);
3131
self::assertArrayHasKey('type', $response);
3232
self::assertSame('documentAdditionOrUpdate', $response['type']);
3333
self::assertArrayHasKey('indexUid', $response);
@@ -40,11 +40,11 @@ public function testGetOneTaskFromWaitTask(): void
4040

4141
public function testGetOneTaskClient(): void
4242
{
43-
[$promise] = $this->seedIndex();
43+
[$task] = $this->seedIndex();
4444

45-
$response = $this->client->getTask($promise['taskUid']);
45+
$response = $this->client->getTask($task['taskUid']);
4646
self::assertArrayHasKey('status', $response);
47-
self::assertSame($response['uid'], $promise['taskUid']);
47+
self::assertSame($response['uid'], $task['taskUid']);
4848
self::assertArrayHasKey('type', $response);
4949
self::assertSame('documentAdditionOrUpdate', $response['type']);
5050
self::assertArrayHasKey('indexUid', $response);
@@ -76,8 +76,8 @@ public function testGetAllTasksClientWithPagination(): void
7676

7777
public function getAllTasksClientWithBatchFilter(): void
7878
{
79-
[$promise] = $this->seedIndex();
80-
$task = $this->client->getTask($promise['taskUid']);
79+
[$task] = $this->seedIndex();
80+
$task = $this->client->getTask($task['taskUid']);
8181

8282
$response = $this->client->getTasks((new TasksQuery())
8383
->setBatchUid($task['uid'])
@@ -88,11 +88,11 @@ public function getAllTasksClientWithBatchFilter(): void
8888

8989
public function testGetOneTaskIndex(): void
9090
{
91-
[$promise] = $this->seedIndex();
91+
[$task] = $this->seedIndex();
9292

93-
$response = $this->index->getTask($promise['taskUid']);
93+
$response = $this->index->getTask($task['taskUid']);
9494
self::assertArrayHasKey('status', $response);
95-
self::assertSame($response['uid'], $promise['taskUid']);
95+
self::assertSame($response['uid'], $task['taskUid']);
9696
self::assertArrayHasKey('type', $response);
9797
self::assertSame('documentAdditionOrUpdate', $response['type']);
9898
self::assertArrayHasKey('indexUid', $response);
@@ -139,10 +139,10 @@ public function testCancelTasksWithFilter(): void
139139
{
140140
$date = new \DateTime('yesterday');
141141
$query = http_build_query(['afterEnqueuedAt' => $date->format(\DateTime::RFC3339)]);
142-
$promise = $this->client->cancelTasks((new CancelTasksQuery())->setAfterEnqueuedAt($date));
142+
$task = $this->client->cancelTasks((new CancelTasksQuery())->setAfterEnqueuedAt($date));
143143

144-
self::assertSame('taskCancelation', $promise['type']);
145-
$response = $this->client->waitForTask($promise['taskUid']);
144+
self::assertSame('taskCancelation', $task['type']);
145+
$response = $this->client->waitForTask($task['taskUid']);
146146

147147
self::assertSame('?'.$query, $response['details']['originalFilter']);
148148
self::assertSame('taskCancelation', $response['type']);
@@ -173,9 +173,9 @@ public function testExceptionIfNoTaskIdWhenGetting(): void
173173

174174
private function seedIndex(): array
175175
{
176-
$promise = $this->index->updateDocuments(self::DOCUMENTS);
177-
$response = $this->client->waitForTask($promise['taskUid']);
176+
$task = $this->index->updateDocuments(self::DOCUMENTS);
177+
$response = $this->client->waitForTask($task['taskUid']);
178178

179-
return [$promise, $response];
179+
return [$task, $response];
180180
}
181181
}

tests/Endpoints/TenantTokenTest.php

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -42,8 +42,8 @@ protected function tearDown(): void
4242

4343
public function testGenerateTenantTokenWithSearchRulesOnly(): void
4444
{
45-
$promise = $this->client->index('tenantToken')->addDocuments(self::DOCUMENTS);
46-
$this->client->waitForTask($promise['taskUid']);
45+
$task = $this->client->index('tenantToken')->addDocuments(self::DOCUMENTS);
46+
$this->client->waitForTask($task['taskUid']);
4747

4848
$token = $this->privateClient->generateTenantToken($this->key->getUid(), ['*']);
4949
$tokenClient = new Client($this->host, $token);
@@ -55,8 +55,8 @@ public function testGenerateTenantTokenWithSearchRulesOnly(): void
5555

5656
public function testGenerateTenantTokenWithSearchRulesAsObject(): void
5757
{
58-
$promise = $this->client->index('tenantToken')->addDocuments(self::DOCUMENTS);
59-
$this->client->waitForTask($promise['taskUid']);
58+
$task = $this->client->index('tenantToken')->addDocuments(self::DOCUMENTS);
59+
$this->client->waitForTask($task['taskUid']);
6060

6161
$token = $this->privateClient->generateTenantToken($this->key->getUid(), (object) ['*' => (object) []]);
6262
$tokenClient = new Client($this->host, $token);
@@ -68,12 +68,12 @@ public function testGenerateTenantTokenWithSearchRulesAsObject(): void
6868

6969
public function testGenerateTenantTokenWithFilter(): void
7070
{
71-
$promise = $this->client->index('tenantToken')->addDocuments(self::DOCUMENTS);
72-
$this->client->waitForTask($promise['taskUid']);
73-
$promiseFromFilter = $this->client->index('tenantToken')->updateFilterableAttributes([
71+
$task = $this->client->index('tenantToken')->addDocuments(self::DOCUMENTS);
72+
$this->client->waitForTask($task['taskUid']);
73+
$taskFromFilter = $this->client->index('tenantToken')->updateFilterableAttributes([
7474
'id',
7575
]);
76-
$this->client->waitForTask($promiseFromFilter['taskUid']);
76+
$this->client->waitForTask($taskFromFilter['taskUid']);
7777

7878
$token = $this->privateClient->generateTenantToken($this->key->getUid(), (object) ['tenantToken' => (object) ['filter' => 'id > 10']]);
7979
$tokenClient = new Client($this->host, $token);

tests/Settings/DisplayedAttributesTest.php

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -25,9 +25,9 @@ public function testUpdateDisplayedAttributes(): void
2525
$newAttributes = ['title'];
2626
$index = $this->createEmptyIndex($this->safeIndexName());
2727

28-
$promise = $index->updateDisplayedAttributes($newAttributes);
28+
$task = $index->updateDisplayedAttributes($newAttributes);
2929

30-
$index->waitForTask($promise['taskUid']);
30+
$index->waitForTask($task['taskUid']);
3131

3232
$displayedAttributes = $index->getDisplayedAttributes();
3333

@@ -39,12 +39,12 @@ public function testResetDisplayedAttributes(): void
3939
$index = $this->createEmptyIndex($this->safeIndexName());
4040
$newAttributes = ['title'];
4141

42-
$promise = $index->updateDisplayedAttributes($newAttributes);
43-
$index->waitForTask($promise['taskUid']);
42+
$task = $index->updateDisplayedAttributes($newAttributes);
43+
$index->waitForTask($task['taskUid']);
4444

45-
$promise = $index->resetDisplayedAttributes();
45+
$task = $index->resetDisplayedAttributes();
4646

47-
$index->waitForTask($promise['taskUid']);
47+
$index->waitForTask($task['taskUid']);
4848

4949
$displayedAttributes = $index->getDisplayedAttributes();
5050
self::assertSame(['*'], $displayedAttributes);

tests/Settings/DistinctAttributeTest.php

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -28,8 +28,8 @@ public function testUpdateDistinctAttribute(): void
2828
{
2929
$distinctAttribute = 'description';
3030

31-
$promise = $this->index->updateDistinctAttribute($distinctAttribute);
32-
$this->index->waitForTask($promise['taskUid']);
31+
$task = $this->index->updateDistinctAttribute($distinctAttribute);
32+
$this->index->waitForTask($task['taskUid']);
3333

3434
self::assertSame($distinctAttribute, $this->index->getDistinctAttribute());
3535
}
@@ -38,11 +38,11 @@ public function testResetDistinctAttribute(): void
3838
{
3939
$distinctAttribute = 'description';
4040

41-
$promise = $this->index->updateDistinctAttribute($distinctAttribute);
42-
$this->index->waitForTask($promise['taskUid']);
41+
$task = $this->index->updateDistinctAttribute($distinctAttribute);
42+
$this->index->waitForTask($task['taskUid']);
4343

44-
$promise = $this->index->resetDistinctAttribute();
45-
$this->index->waitForTask($promise['taskUid']);
44+
$task = $this->index->resetDistinctAttribute();
45+
$this->index->waitForTask($task['taskUid']);
4646

4747
self::assertNull($this->index->getDistinctAttribute());
4848
}

0 commit comments

Comments
 (0)