Skip to content

Commit 6829582

Browse files
committed
Add test on UnifiedTestRunner EntityMapObserver
1 parent f81b4a6 commit 6829582

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
@@ -126,6 +126,8 @@ public function run(UnifiedTestCase $test): void
126126
*
127127
* This function is primarily used by the Atlas testing workload executor.
128128
*
129+
* @see https://github.com/mongodb-labs/drivers-atlas-testing/
130+
*
129131
* @param callable(EntityMap):void $entityMapObserver
130132
*/
131133
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)