Skip to content

Commit 96d27b7

Browse files
committed
Checks for crypt_shared and/or mongocryptd in FunctionalTestCase::skipIfClientSideEncryptionIsNotSupported
1 parent 5d8be5d commit 96d27b7

File tree

4 files changed

+10
-11
lines changed

4 files changed

+10
-11
lines changed

tests/DocumentationExamplesTest.php

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1810,10 +1810,7 @@ public function testQueryableEncryption(): void
18101810
}
18111811

18121812
$this->skipIfServerVersion('<', '7.0.0', 'Explicit encryption tests require MongoDB 7.0 or later');
1813-
1814-
if (! static::isCryptSharedLibAvailable() && ! static::isMongocryptdAvailable()) {
1815-
$this->markTestSkipped('Neither crypt_shared nor mongocryptd are available');
1816-
}
1813+
$this->skipIfClientSideEncryptionIsNotSupported();
18171814

18181815
// Fetch names for the database and collection under test
18191816
$collectionName = $this->getCollectionName();

tests/FunctionalTestCase.php

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -531,6 +531,10 @@ protected function skipIfClientSideEncryptionIsNotSupported(): void
531531
if (static::getModuleInfo('libmongocrypt') === 'disabled') {
532532
$this->markTestSkipped('Client Side Encryption is not enabled in the MongoDB extension');
533533
}
534+
535+
if (! static::isCryptSharedLibAvailable() && ! static::isMongocryptdAvailable()) {
536+
$this->markTestSkipped('Neither crypt_shared nor mongocryptd are available');
537+
}
534538
}
535539

536540
protected function skipIfGeoHaystackIndexIsNotSupported(): void
@@ -568,7 +572,7 @@ protected function skipIfTransactionsAreNotSupported(): void
568572
}
569573

570574
/** @see https://www.mongodb.com/docs/manual/core/queryable-encryption/reference/shared-library/ */
571-
protected static function isCryptSharedLibAvailable(): bool
575+
public static function isCryptSharedLibAvailable(): bool
572576
{
573577
$cryptSharedLibPath = getenv('CRYPT_SHARED_LIB_PATH');
574578

@@ -580,7 +584,7 @@ protected static function isCryptSharedLibAvailable(): bool
580584
}
581585

582586
/** @see https://www.mongodb.com/docs/manual/core/queryable-encryption/reference/mongocryptd/ */
583-
protected static function isMongocryptdAvailable(): bool
587+
public static function isMongocryptdAvailable(): bool
584588
{
585589
$paths = explode(PATH_SEPARATOR, getenv("PATH"));
586590

tests/SpecTests/ClientSideEncryptionSpecTest.php

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -117,10 +117,6 @@ public function setUp(): void
117117
parent::setUp();
118118

119119
$this->skipIfClientSideEncryptionIsNotSupported();
120-
121-
if (! static::isCryptSharedLibAvailable() && ! static::isMongocryptdAvailable()) {
122-
$this->markTestSkipped('Neither crypt_shared nor mongocryptd are available');
123-
}
124120
}
125121

126122
/**

tests/UnifiedSpecTests/UnifiedTestRunner.php

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -337,6 +337,8 @@ private function isAuthenticated(): bool
337337

338338
/**
339339
* Return whether client-side encryption is supported.
340+
*
341+
* @see FunctionalTestCase::skipIfClientSideEncryptionIsNotSupported()
340342
*/
341343
private function isClientSideEncryptionSupported(): bool
342344
{
@@ -350,7 +352,7 @@ private function isClientSideEncryptionSupported(): bool
350352
return false;
351353
}
352354

353-
return static::isCryptSharedLibAvailable() || static::isMongocryptdAvailable();
355+
return FunctionalTestCase::isCryptSharedLibAvailable() || FunctionalTestCase::isMongocryptdAvailable();
354356
}
355357

356358
/**

0 commit comments

Comments
 (0)