diff --git a/tests/UnifiedSpecTests/UnifiedTestRunner.php b/tests/UnifiedSpecTests/UnifiedTestRunner.php index 27f953a89..35a0ec456 100644 --- a/tests/UnifiedSpecTests/UnifiedTestRunner.php +++ b/tests/UnifiedSpecTests/UnifiedTestRunner.php @@ -125,6 +125,8 @@ public function run(UnifiedTestCase $test): void * * This function is primarily used by the Atlas testing workload executor. * + * @see https://github.com/mongodb-labs/drivers-atlas-testing/ + * * @param callable(EntityMap):void $entityMapObserver */ public function setEntityMapObserver(callable $entityMapObserver): void diff --git a/tests/UnifiedSpecTests/UnifiedTestRunnerTest.php b/tests/UnifiedSpecTests/UnifiedTestRunnerTest.php new file mode 100644 index 000000000..d9e9c37ca --- /dev/null +++ b/tests/UnifiedSpecTests/UnifiedTestRunnerTest.php @@ -0,0 +1,25 @@ +setEntityMapObserver(function (EntityMap $entityMap) use (&$calls): void { + $this->assertArrayHasKey('client0', $entityMap); + $this->assertArrayHasKey('database0', $entityMap); + $this->assertArrayHasKey('collection0', $entityMap); + $calls++; + }); + + $runner->run($test->current()); + $this->assertSame(1, $calls); + } +} diff --git a/tests/UnifiedSpecTests/runner/entity-map-observer.json b/tests/UnifiedSpecTests/runner/entity-map-observer.json new file mode 100644 index 000000000..833600950 --- /dev/null +++ b/tests/UnifiedSpecTests/runner/entity-map-observer.json @@ -0,0 +1,68 @@ +{ + "description": "find", + "schemaVersion": "1.0", + "createEntities": [ + { + "client": { + "id": "client0", + "useMultipleMongoses": true, + "observeEvents": [ + "commandStartedEvent" + ] + } + }, + { + "database": { + "id": "database0", + "client": "client0", + "databaseName": "runner-tests" + } + }, + { + "collection": { + "id": "collection0", + "database": "database0", + "collectionName": "coll0" + } + } + ], + "initialData": [ + { + "collectionName": "coll0", + "databaseName": "runner-tests", + "documents": [] + } + ], + "tests": [ + { + "description": "basic find", + "operations": [ + { + "name": "find", + "arguments": { + "filter": {} + }, + "object": "collection0", + "expectResult": [] + } + ], + "expectEvents": [ + { + "client": "client0", + "events": [ + { + "commandStartedEvent": { + "command": { + "find": "coll0", + "filter": {} + }, + "commandName": "find", + "databaseName": "runner-tests" + } + } + ] + } + ] + } + ] +}