Skip to content

Commit 3a0bef4

Browse files
committed
PHPLIB-743: Ignore extra metadata queries in CSFLE spec tests
1 parent c4302b9 commit 3a0bef4

File tree

1 file changed

+23
-2
lines changed

1 file changed

+23
-2
lines changed

tests/SpecTests/CommandExpectations.php

Lines changed: 23 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,9 @@ class CommandExpectations implements CommandSubscriber
3939
/** @var boolean */
4040
private $ignoreExtraEvents = false;
4141

42+
/** @var boolean */
43+
private $ignoreKeyVaultListCollections = false;
44+
4245
/** @var string[] */
4346
private $ignoredCommandNames = [];
4447

@@ -87,6 +90,7 @@ public static function fromClientSideEncryption(array $expectedEvents)
8790

8891
$o->ignoreCommandFailed = true;
8992
$o->ignoreCommandSucceeded = true;
93+
$o->ignoreKeyVaultListCollections = true;
9094

9195
return $o;
9296
}
@@ -254,7 +258,24 @@ public function assert(FunctionalTestCase $test, Context $context): void
254258

255259
private function isEventIgnored($event)
256260
{
257-
return ($this->ignoreExtraEvents && count($this->actualEvents) === count($this->expectedEvents))
258-
|| in_array($event->getCommandName(), $this->ignoredCommandNames);
261+
if ($this->ignoreExtraEvents && count($this->actualEvents) === count($this->expectedEvents)) {
262+
return true;
263+
}
264+
265+
if (in_array($event->getCommandName(), $this->ignoredCommandNames)) {
266+
return true;
267+
}
268+
269+
/* Note: libmongoc does not use a separate MongoClient to query for
270+
* CSFLE metadata (DRIVERS-1459). Since the tests do not expect this
271+
* command, we must ignore it. */
272+
if (
273+
$this->ignoreKeyVaultListCollections && $event instanceof CommandStartedEvent &&
274+
$event->getCommandName() === 'listCollections' && $event->getDatabaseName() === 'keyvault'
275+
) {
276+
return true;
277+
}
278+
279+
return false;
259280
}
260281
}

0 commit comments

Comments
 (0)