public function MongoDbTest::testLibraryVersion in MongoDB 8.2
@covers ::libraryApiVersion
File
- modules/
mongodb/ tests/ src/ Kernel/ MongoDbTest.php, line 22
Class
- MongoDbTest
- Tests the MongoDB main class.
Namespace
Drupal\Tests\mongodb\KernelCode
public function testLibraryVersion() {
$actual = MongoDb::libraryApiVersion();
$this
->assertRegExp('/[\\d]\\.[\\d]+\\.[\\d]+/', $actual, 'API version matches expected format.');
list(, $minor, ) = sscanf($actual, "%d.%d.%d");
$hasWatch = method_exists(Collection::class, 'watch');
$hasCountDocuments = method_exists(Collection::class, 'countDocuments');
switch ($minor) {
case 2:
$this
->assertFalse($hasWatch);
$this
->assertFalse($hasCountDocuments);
break;
case 3:
$this
->assertTrue($hasWatch);
$this
->assertFalse($hasCountDocuments);
break;
case 4:
$this
->assertTrue($hasWatch);
$this
->assertTrue($hasCountDocuments);
break;
default:
$this
->fail("Unexpected API version: {$actual}");
}
}