@@ -953,9 +953,8 @@ public function testChangeStreamExample_1_4(): void
953
953
$ this ->markTestSkipped ('Test does not apply on sharded clusters: need more than a single getMore call on the change stream. ' );
954
954
}
955
955
956
- $ this ->dropCollection ($ this ->getDatabaseName (), 'inventory ' );
956
+ $ this ->createCollection ($ this ->getDatabaseName (), 'inventory ' );
957
957
$ db = new Database ($ this ->manager , $ this ->getDatabaseName ());
958
- $ db ->createCollection ('inventory ' );
959
958
960
959
// Start Changestream Example 1
961
960
$ changeStream = $ db ->inventory ->watch ();
@@ -1189,9 +1188,8 @@ public function testRunCommand_example_1(): void
1189
1188
1190
1189
public function testRunCommand_example_2 (): void
1191
1190
{
1192
- $ this ->dropCollection ($ this ->getDatabaseName (), 'restaurants ' );
1191
+ $ this ->createCollection ($ this ->getDatabaseName (), 'restaurants ' );
1193
1192
$ db = new Database ($ this ->manager , $ this ->getDatabaseName ());
1194
- $ db ->createCollection ('restaurants ' );
1195
1193
1196
1194
// Start runCommand Example 2
1197
1195
$ cursor = $ db ->command (['collStats ' => 'restaurants ' ]);
@@ -1290,9 +1288,6 @@ public function testTransactions_intro_example_1(): void
1290
1288
1291
1289
$ client = static ::createTestClient ();
1292
1290
1293
- $ this ->dropCollection ('hr ' , 'employees ' );
1294
- $ this ->dropCollection ('reporting ' , 'events ' );
1295
-
1296
1291
/* Collections need to be created before a transaction starts */
1297
1292
$ this ->createCollection ('hr ' , 'employees ' );
1298
1293
$ this ->createCollection ('reporting ' , 'events ' );
@@ -1469,9 +1464,6 @@ public function testTransactions_retry_example_3(): void
1469
1464
1470
1465
$ client = static ::createTestClient ();
1471
1466
1472
- $ this ->dropCollection ('hr ' , 'employees ' );
1473
- $ this ->dropCollection ('reporting ' , 'events ' );
1474
-
1475
1467
/* Collections need to be created before a transaction starts */
1476
1468
$ this ->createCollection ('hr ' , 'employees ' );
1477
1469
$ this ->createCollection ('reporting ' , 'events ' );
@@ -1491,12 +1483,8 @@ public function testCausalConsistency(): void
1491
1483
$ this ->assertNotNull ('This test intentionally performs no assertions ' );
1492
1484
1493
1485
// Prep
1494
- $ this ->dropCollection ('test ' , 'items ' );
1495
1486
$ client = static ::createTestClient ();
1496
- $ items = $ client ->selectDatabase (
1497
- 'test ' ,
1498
- ['writeConcern ' => new WriteConcern (WriteConcern::MAJORITY )]
1499
- )->items ;
1487
+ $ items = $ this ->createCollection ('test ' , 'items ' );
1500
1488
$ items ->insertOne (
1501
1489
['sku ' => '111 ' , 'name ' => 'Peanuts ' , 'start ' => new UTCDateTime ()]
1502
1490
);
@@ -1865,17 +1853,16 @@ public function testQueryableEncryption(): void
1865
1853
$ this ->markTestSkipped ('Automatic encryption requires MongoDB Enterprise ' );
1866
1854
}
1867
1855
1856
+ // Ensure the collection is dropped by tearDown()
1868
1857
$ this ->dropCollection ($ this ->getDatabaseName (), $ this ->getCollectionName ());
1869
1858
1870
1859
// Fetch names for the database and collection under test
1871
1860
$ collectionName = $ this ->getCollectionName ();
1872
1861
$ databaseName = $ this ->getDatabaseName ();
1873
1862
$ namespace = $ this ->getNamespace ();
1874
1863
1875
- /* Create a client without auto encryption. Drop existing data in both
1876
- * the keyvault and database under test. The latter is necessary since
1877
- * setUp() only drops the collection under test, which will leave behind
1878
- * internal collections for queryable encryption. */
1864
+ /* Create a client without auto encryption. Drop existing data in both the keyvault and database under test.
1865
+ * The latter is necessary to clean up any internal collections for queryable encryption. */
1879
1866
$ client = static ::createTestClient ();
1880
1867
$ client ->selectDatabase ('keyvault ' )->drop (['writeConcern ' => new WriteConcern (WriteConcern::MAJORITY )]);
1881
1868
$ client ->selectDatabase ($ databaseName )->drop (['writeConcern ' => new WriteConcern (WriteConcern::MAJORITY )]);
0 commit comments