@@ -1194,11 +1194,10 @@ public function testRunCommand_example_1(): void
1194
1194
public function testRunCommand_example_2 (): void
1195
1195
{
1196
1196
$ db = new Database ($ this ->manager , $ this ->getDatabaseName ());
1197
- $ db ->dropCollection ('restaurants ' );
1198
- $ db ->createCollection ('restaurants ' );
1197
+ $ db ->createCollection ('inventory ' );
1199
1198
1200
1199
// Start runCommand Example 2
1201
- $ cursor = $ db ->command (['collStats ' => 'restaurants ' ]);
1200
+ $ cursor = $ db ->command (['collStats ' => 'inventory ' ]);
1202
1201
$ result = $ cursor ->toArray ()[0 ];
1203
1202
// End runCommand Example 2
1204
1203
@@ -1210,7 +1209,7 @@ public function testIndex_example_1(): void
1210
1209
$ db = new Database ($ this ->manager , $ this ->getDatabaseName ());
1211
1210
1212
1211
// Start Index Example 1
1213
- $ indexName = $ db ->records ->createIndex (['score ' => 1 ]);
1212
+ $ indexName = $ db ->inventory ->createIndex (['score ' => 1 ]);
1214
1213
// End Index Example 1
1215
1214
1216
1215
$ this ->assertEquals ('score_1 ' , $ indexName );
@@ -1221,7 +1220,7 @@ public function testIndex_example_2(): void
1221
1220
$ db = new Database ($ this ->manager , $ this ->getDatabaseName ());
1222
1221
1223
1222
// Start Index Example 2
1224
- $ indexName = $ db ->restaurants ->createIndex (
1223
+ $ indexName = $ db ->inventory ->createIndex (
1225
1224
['cuisine ' => 1 , 'name ' => 1 ],
1226
1225
['partialFilterExpression ' => ['rating ' => ['$gt ' => 5 ]]]
1227
1226
);
@@ -1496,13 +1495,14 @@ public function testCausalConsistency(): void
1496
1495
1497
1496
// Prep
1498
1497
$ client = static ::createTestClient ();
1499
- $ items = $ client ->selectDatabase (
1500
- 'test ' ,
1498
+ $ databaseName = $ this ->getDatabaseName ();
1499
+ $ inventory = $ client ->selectDatabase (
1500
+ $ databaseName ,
1501
1501
['writeConcern ' => new WriteConcern (WriteConcern::MAJORITY )]
1502
- )->items ;
1502
+ )->inventory ;
1503
1503
1504
- $ items ->drop ();
1505
- $ items ->insertOne (
1504
+ $ inventory ->drop ();
1505
+ $ inventory ->insertOne (
1506
1506
['sku ' => '111 ' , 'name ' => 'Peanuts ' , 'start ' => new UTCDateTime ()]
1507
1507
);
1508
1508
@@ -1511,33 +1511,33 @@ public function testCausalConsistency(): void
1511
1511
* mode, so using $manager->selectServer does not work here. To work
1512
1512
* around this, we run a query on a secondary and rely on an
1513
1513
* exception to let us know that no secondary is available. */
1514
- $ items ->countDocuments ([], ['readPreference ' => new ReadPreference (ReadPreference::RP_SECONDARY )]);
1514
+ $ inventory ->countDocuments ([], ['readPreference ' => new ReadPreference (ReadPreference::RP_SECONDARY )]);
1515
1515
} catch (Exception $ e ) {
1516
1516
$ this ->markTestSkipped ('Secondary is not available ' );
1517
1517
}
1518
1518
1519
1519
// phpcs:disable SlevomatCodingStandard.Namespaces.ReferenceUsedNamesOnly
1520
1520
// Start Causal Consistency Example 1
1521
- $ items = $ client ->selectDatabase (
1522
- ' test ' ,
1521
+ $ inventory = $ client ->selectDatabase (
1522
+ $ databaseName ,
1523
1523
[
1524
1524
'readConcern ' => new \MongoDB \Driver \ReadConcern (\MongoDB \Driver \ReadConcern::MAJORITY ),
1525
1525
'writeConcern ' => new \MongoDB \Driver \WriteConcern (\MongoDB \Driver \WriteConcern::MAJORITY , 1000 ),
1526
1526
]
1527
- )->items ;
1527
+ )->inventory ;
1528
1528
1529
1529
$ s1 = $ client ->startSession (
1530
1530
['causalConsistency ' => true ]
1531
1531
);
1532
1532
1533
1533
$ currentDate = new \MongoDB \BSON \UTCDateTime ();
1534
1534
1535
- $ items ->updateOne (
1535
+ $ inventory ->updateOne (
1536
1536
['sku ' => '111 ' , 'end ' => ['$exists ' => false ]],
1537
1537
['$set ' => ['end ' => $ currentDate ]],
1538
1538
['session ' => $ s1 ]
1539
1539
);
1540
- $ items ->insertOne (
1540
+ $ inventory ->insertOne (
1541
1541
['sku ' => '111-nuts ' , 'name ' => 'Pecans ' , 'start ' => $ currentDate ],
1542
1542
['session ' => $ s1 ]
1543
1543
);
@@ -1554,16 +1554,16 @@ public function testCausalConsistency(): void
1554
1554
$ s2 ->advanceClusterTime ($ s1 ->getClusterTime ());
1555
1555
$ s2 ->advanceOperationTime ($ s1 ->getOperationTime ());
1556
1556
1557
- $ items = $ client ->selectDatabase (
1558
- ' test ' ,
1557
+ $ inventory = $ client ->selectDatabase (
1558
+ $ databaseName ,
1559
1559
[
1560
1560
'readPreference ' => new \MongoDB \Driver \ReadPreference (\MongoDB \Driver \ReadPreference::RP_SECONDARY ),
1561
1561
'readConcern ' => new \MongoDB \Driver \ReadConcern (\MongoDB \Driver \ReadConcern::MAJORITY ),
1562
1562
'writeConcern ' => new \MongoDB \Driver \WriteConcern (\MongoDB \Driver \WriteConcern::MAJORITY , 1000 ),
1563
1563
]
1564
- )->items ;
1564
+ )->inventory ;
1565
1565
1566
- $ result = $ items ->find (
1566
+ $ result = $ inventory ->find (
1567
1567
['end ' => ['$exists ' => false ]],
1568
1568
['session ' => $ s2 ]
1569
1569
);
0 commit comments