File tree Expand file tree Collapse file tree 4 files changed +46
-3
lines changed Expand file tree Collapse file tree 4 files changed +46
-3
lines changed Original file line number Diff line number Diff line change @@ -81,4 +81,10 @@ Delete a collection
81
81
```
82
82
$arangoClient->schema()->deleteCollection('users');
83
83
```
84
+ ### deleteAllCollections(): bool
85
+ This method deletes all non-system collections available on the current database.
86
+
87
+ ```
88
+ $arangoClient->schema()->deleteAllCollections();
89
+ ```
84
90
Original file line number Diff line number Diff line change @@ -71,9 +71,7 @@ public function deleteAllAnalyzers(): bool
71
71
continue ;
72
72
}
73
73
74
- $ uri = '/_api/analyzer/ ' . $ analyzer ->name ;
75
-
76
- $ this ->arangoClient ->request ('delete ' , $ uri );
74
+ $ this ->deleteAnalyzer ($ analyzer ->name );
77
75
}
78
76
79
77
return true ;
Original file line number Diff line number Diff line change @@ -214,4 +214,18 @@ public function deleteCollection(string $name): bool
214
214
215
215
return (bool ) $ this ->arangoClient ->request ('delete ' , $ uri );
216
216
}
217
+
218
+ /**
219
+ * @throws ArangoException
220
+ */
221
+ public function deleteAllCollections (): bool
222
+ {
223
+ $ collections = $ this ->getCollections (true );
224
+
225
+ foreach ($ collections as $ collection ) {
226
+ $ this ->deleteCollection ($ collection ->name );
227
+ }
228
+
229
+ return true ;
230
+ }
217
231
}
Original file line number Diff line number Diff line change 192
192
193
193
$ this ->schemaManager ->deleteCollection ($ collection );
194
194
});
195
+
196
+ test ('deleteAllCollections ' , function () {
197
+ $ collection1 = 'collection1 ' ;
198
+ $ collection2 = 'collection2 ' ;
199
+
200
+ if (!$ this ->schemaManager ->hasCollection ($ collection1 )) {
201
+ $ result = $ this ->schemaManager ->createCollection ($ collection1 , []);
202
+ expect ($ result ->name )->toEqual ($ collection1 );
203
+ }
204
+
205
+ if (!$ this ->schemaManager ->hasCollection ($ collection2 )) {
206
+ $ result = $ this ->schemaManager ->createCollection ($ collection2 , []);
207
+ expect ($ result ->name )->toEqual ($ collection2 );
208
+ }
209
+
210
+ $ createdCollections = $ this ->schemaManager ->getCollections (true );
211
+
212
+ $ result = $ this ->schemaManager ->deleteAllCollections ();
213
+
214
+ $ finalCollections = $ this ->schemaManager ->getCollections (true );
215
+
216
+ expect ($ result )->toBeTrue ();
217
+ expect (count ($ createdCollections ))->toBe (2 );
218
+ expect (count ($ finalCollections ))->toBe (0 );
219
+ });
You can’t perform that action at this time.
0 commit comments