Skip to content

Commit 8c0ff42

Browse files
committed
Compare serverConnectionId instead of Server instance as Event::getServer is deprecated
1 parent c6f9f00 commit 8c0ff42

File tree

3 files changed

+15
-13
lines changed

3 files changed

+15
-13
lines changed

tests/SpecTests/RetryableReads/Prose2_RetryOnMongosTest.php

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -65,7 +65,8 @@ public function testRetryOnDifferentMongos(): void
6565

6666
// Step 4: Enable failed command event monitoring for client
6767
$subscriber = new class implements CommandSubscriber {
68-
public $commandFailedServers = [];
68+
/** @var int[] */
69+
public array $commandFailedServers = [];
6970

7071
public function commandStarted(CommandStartedEvent $event): void
7172
{
@@ -77,7 +78,7 @@ public function commandSucceeded(CommandSucceededEvent $event): void
7778

7879
public function commandFailed(CommandFailedEvent $event): void
7980
{
80-
$this->commandFailedServers[] = $event->getServer();
81+
$this->commandFailedServers[] = $event->getServerConnectionId();
8182
}
8283
};
8384

@@ -130,21 +131,21 @@ public function testRetryOnSameMongos(): void
130131

131132
// Step 4: Enable succeeded and failed command event monitoring
132133
$subscriber = new class implements CommandSubscriber {
133-
public Server $commandSucceededServer;
134-
public Server $commandFailedServer;
134+
public ?int $commandSucceededServer = null;
135+
public ?int $commandFailedServer = null;
135136

136137
public function commandStarted(CommandStartedEvent $event): void
137138
{
138139
}
139140

140141
public function commandSucceeded(CommandSucceededEvent $event): void
141142
{
142-
$this->commandSucceededServer = $event->getServer();
143+
$this->commandSucceededServer = $event->getServerConnectionId();
143144
}
144145

145146
public function commandFailed(CommandFailedEvent $event): void
146147
{
147-
$this->commandFailedServer = $event->getServer();
148+
$this->commandFailedServer = $event->getServerConnectionId();
148149
}
149150
};
150151

tests/SpecTests/RetryableWrites/Prose4_RetryOnDifferentMongosTest.php

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -67,7 +67,8 @@ public function testRetryOnDifferentMongos(): void
6767

6868
// Step 4: Enable failed command event monitoring for client
6969
$subscriber = new class implements CommandSubscriber {
70-
public $commandFailedServers = [];
70+
/** @var int[] */
71+
public array $commandFailedServers = [];
7172

7273
public function commandStarted(CommandStartedEvent $event): void
7374
{
@@ -79,7 +80,7 @@ public function commandSucceeded(CommandSucceededEvent $event): void
7980

8081
public function commandFailed(CommandFailedEvent $event): void
8182
{
82-
$this->commandFailedServers[] = $event->getServer();
83+
$this->commandFailedServers[] = $event->getServerConnectionId();
8384
}
8485
};
8586

tests/SpecTests/RetryableWrites/Prose5_RetryOnSameMongosTest.php

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -50,21 +50,21 @@ public function testRetryOnSameMongos(): void
5050

5151
// Step 4: Enable succeeded and failed command event monitoring
5252
$subscriber = new class implements CommandSubscriber {
53-
public Server $commandSucceededServer;
54-
public Server $commandFailedServer;
53+
public ?int $commandSucceededServer = null;
54+
public ?int $commandFailedServer = null;
5555

5656
public function commandStarted(CommandStartedEvent $event): void
5757
{
5858
}
5959

6060
public function commandSucceeded(CommandSucceededEvent $event): void
6161
{
62-
$this->commandSucceededServer = $event->getServer();
62+
$this->commandSucceededServer = $event->getServerConnectionId();
6363
}
6464

6565
public function commandFailed(CommandFailedEvent $event): void
6666
{
67-
$this->commandFailedServer = $event->getServer();
67+
$this->commandFailedServer = $event->getServerConnectionId();
6868
}
6969
};
7070

@@ -78,7 +78,7 @@ public function commandFailed(CommandFailedEvent $event): void
7878

7979
/* Step 6: Assert that exactly one failed command event and one
8080
* succeeded command event occurred. Assert that both events occurred on
81-
* the same mongos. */
81+
* the same mongos connection. */
8282
$this->assertNotNull($subscriber->commandSucceededServer);
8383
$this->assertNotNull($subscriber->commandFailedServer);
8484
$this->assertEquals($subscriber->commandSucceededServer, $subscriber->commandFailedServer);

0 commit comments

Comments
 (0)