1--TEST--
2Retryable reads: executeQuery is not retried when retryable reads are disabled
3--SKIPIF--
4<?php require __DIR__ . "/../utils/basic-skipif.inc"; ?>
5<?php skip_if_not_libmongoc_crypto(); ?>
6<?php skip_if_no_failcommand_failpoint(); ?>
7--FILE--
8<?php
9require_once __DIR__ . "/../utils/basic.inc";
10
11class Observer implements MongoDB\Driver\Monitoring\CommandSubscriber
12{
13    public function commandStarted(MongoDB\Driver\Monitoring\CommandStartedEvent $event)
14    {
15        printf("Command started: %s\n", $event->getCommandName());
16    }
17
18    public function commandSucceeded(MongoDB\Driver\Monitoring\CommandSucceededEvent $event)
19    {
20    }
21
22    public function commandFailed(MongoDB\Driver\Monitoring\CommandFailedEvent $event)
23    {
24    }
25}
26
27$manager = new MongoDB\Driver\Manager(URI, ['retryReads' => false]);
28
29// Select a specific server for future operations to avoid mongos switching in sharded clusters
30$server = $manager->selectServer(new \MongoDB\Driver\ReadPreference('primary'));
31
32configureTargetedFailPoint($server, 'failCommand', ['times' => 1], ['failCommands' => ['find'], 'closeConnection' => true]);
33
34$observer = new Observer;
35MongoDB\Driver\Monitoring\addSubscriber($observer);
36
37throws(
38    function() use ($server) {
39        $server->executeQuery(NS, new \MongoDB\Driver\Query(['x' => 1]));
40    },
41    \MongoDB\Driver\Exception\ConnectionTimeoutException::class
42);
43
44?>
45===DONE===
46<?php exit(0); ?>
47--EXPECT--
48Command started: find
49OK: Got MongoDB\Driver\Exception\ConnectionTimeoutException
50===DONE===
51