Skip to content

Commit

Permalink
Add test on UnifiedTestRunner EntityMapObserver
Browse files Browse the repository at this point in the history
  • Loading branch information
GromNaN committed Jul 17, 2023
1 parent f81b4a6 commit 6829582
Show file tree
Hide file tree
Showing 2 changed files with 27 additions and 0 deletions.
2 changes: 2 additions & 0 deletions tests/UnifiedSpecTests/UnifiedTestRunner.php
Original file line number Diff line number Diff line change
Expand Up @@ -126,6 +126,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
Expand Down
25 changes: 25 additions & 0 deletions tests/UnifiedSpecTests/UnifiedTestRunnerTest.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
<?php

namespace MongoDB\Tests\UnifiedSpecTests;

use MongoDB\Tests\FunctionalTestCase;

class UnifiedTestRunnerTest extends FunctionalTestCase
{
public function testEntityMapObserver(): void
{
$test = UnifiedTestCase::fromFile(__DIR__ . '/crud/find.json');
$calls = 0;

$runner = new UnifiedTestRunner(static::getUri());
$runner->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);
}
}

0 comments on commit 6829582

Please sign in to comment.