Skip to content

Commit 1420868

Browse files
committed
PHPLIB-510: Implement FLE spec tests
1 parent e219420 commit 1420868

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

48 files changed

+22330
-6
lines changed

tests/FunctionalTestCase.php

Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -375,6 +375,17 @@ protected function skipIfCausalConsistencyIsNotSupported()
375375
}
376376
}
377377

378+
protected function skipIfClientSideEncryptionIsNotSupported()
379+
{
380+
if (version_compare($this->getFeatureCompatibilityVersion(), '4.2', '<')) {
381+
$this->markTestSkipped('Client Side Encryption only supported on FCV 4.2 or higher');
382+
}
383+
384+
if ($this->getModuleInfo('libmongocrypt') === 'disabled') {
385+
$this->markTestSkipped('Client Side Encryption is not enabled in the MongoDB extension');
386+
}
387+
}
388+
378389
protected function skipIfTransactionsAreNotSupported()
379390
{
380391
if ($this->getPrimaryServer()->getType() === Server::TYPE_STANDALONE) {
@@ -420,6 +431,26 @@ private function disableFailPoints()
420431
}
421432
}
422433

434+
/**
435+
* @param string $row
436+
*
437+
* @return string|null
438+
*/
439+
private function getModuleInfo($row)
440+
{
441+
ob_start();
442+
phpinfo(INFO_MODULES);
443+
$info = ob_get_clean();
444+
445+
$pattern = sprintf('/^%s([\w ]+)$/m', preg_quote($row . ' => '));
446+
447+
if (preg_match($pattern, $info, $matches) !== 1) {
448+
return null;
449+
}
450+
451+
return $matches[1];
452+
}
453+
423454
/**
424455
* Checks if the failCommand command is supported on this server version
425456
*

tests/SpecTests/ChangeStreamsSpecTest.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -180,7 +180,7 @@ private function createChangeStream(stdClass $test)
180180

181181
switch ($test->target) {
182182
case 'client':
183-
return $context->client->watch($pipeline, $options);
183+
return $context->getClient()->watch($pipeline, $options);
184184
case 'database':
185185
return $context->getDatabase()->watch($pipeline, $options);
186186
case 'collection':
@@ -228,7 +228,7 @@ private function dropDatabasesAndCreateCollection($databaseName, $collectionName
228228
{
229229
$context = $this->getContext();
230230

231-
$database = $context->client->selectDatabase($databaseName);
231+
$database = $context->getClient()->selectDatabase($databaseName);
232232
$database->drop($context->defaultWriteOptions);
233233
$database->createCollection($collectionName, $context->defaultWriteOptions);
234234
}

0 commit comments

Comments
 (0)