DatabaseCommandFunctionalTest.php 925 Bytes
Newer Older
1 2 3 4 5 6
<?php

namespace MongoDB\Tests\Operation;

use MongoDB\Operation\DatabaseCommand;
use MongoDB\Tests\CommandObserver;
7
use function version_compare;
8 9 10 11 12 13 14 15 16

class DatabaseCommandFunctionalTest extends FunctionalTestCase
{
    public function testSessionOption()
    {
        if (version_compare($this->getServerVersion(), '3.6.0', '<')) {
            $this->markTestSkipped('Sessions are not supported');
        }

17 18
        (new CommandObserver())->observe(
            function () {
19 20 21 22 23 24 25 26
                $operation = new DatabaseCommand(
                    $this->getDatabaseName(),
                    ['ping' => 1],
                    ['session' => $this->createSession()]
                );

                $operation->execute($this->getPrimaryServer());
            },
27
            function (array $event) {
28
                $this->assertObjectHasAttribute('lsid', $event['started']->getCommand());
29 30 31 32
            }
        );
    }
}