Skip to content

Commit e35dd05

Browse files
committed
Add test on UnifiedTestRunner EntityMapObserver
1 parent 9e1971c commit e35dd05

File tree

2 files changed

+27
-0
lines changed

2 files changed

+27
-0
lines changed

tests/UnifiedSpecTests/UnifiedTestRunner.php

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -125,6 +125,8 @@ public function run(UnifiedTestCase $test): void
125125
*
126126
* This function is primarily used by the Atlas testing workload executor.
127127
*
128+
* @see https://github.com/mongodb-labs/drivers-atlas-testing/
129+
*
128130
* @param callable(EntityMap):void $entityMapObserver
129131
*/
130132
public function setEntityMapObserver(callable $entityMapObserver): void
Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
<?php
2+
3+
namespace MongoDB\Tests\UnifiedSpecTests;
4+
5+
use MongoDB\Tests\FunctionalTestCase;
6+
7+
class UnifiedTestRunnerTest extends FunctionalTestCase
8+
{
9+
public function testEntityMapObserver(): void
10+
{
11+
$test = UnifiedTestCase::fromFile(__DIR__ . '/crud/find.json');
12+
$calls = 0;
13+
14+
$runner = new UnifiedTestRunner(static::getUri());
15+
$runner->setEntityMapObserver(function (EntityMap $entityMap) use (&$calls): void {
16+
$this->assertArrayHasKey('client0', $entityMap);
17+
$this->assertArrayHasKey('database0', $entityMap);
18+
$this->assertArrayHasKey('collection0', $entityMap);
19+
$calls++;
20+
});
21+
22+
$runner->run($test->current());
23+
$this->assertSame(1, $calls);
24+
}
25+
}

0 commit comments

Comments
 (0)