Skip to content

Commit 469f081

Browse files
committed
Add missing handler for resource subscribe and unsubscribe
1 parent c11f1ff commit 469f081

2 files changed

Lines changed: 8 additions & 8 deletions

File tree

src/Server/Session/Psr16StoreSession.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -114,7 +114,7 @@ public function getAllSessionIds(): array
114114
if (\count($validSessionIds) !== \count($sessionIdsData)) {
115115
$this->cache->set(
116116
self::SESSION_IDS_KEY,
117-
array_map(fn (Uuid $id) => $id->toRfc4122(), $validSessionIds),
117+
array_map(static fn (Uuid $id) => $id->toRfc4122(), $validSessionIds),
118118
null
119119
);
120120
}
@@ -156,7 +156,7 @@ private function removeSessionId(Uuid $id): void
156156
$idString = $id->toRfc4122();
157157
$sessionIds = array_values(array_filter(
158158
$sessionIds,
159-
fn ($sid) => $sid !== $idString
159+
static fn ($sid) => $sid !== $idString
160160
));
161161

162162
$this->cache->set(self::SESSION_IDS_KEY, $sessionIds, null);

tests/Unit/Server/SessionSubscriptionManagerTest.php

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -76,7 +76,7 @@ public function testSubscribeAndSendsNotification(): void
7676

7777
$this->sessionStore->expects($this->exactly(2))
7878
->method('read')
79-
->willReturnCallback(function ($id) use ($uuid1, $uuid2, $sessionData1, $sessionData2) {
79+
->willReturnCallback(static function ($id) use ($uuid1, $uuid2, $sessionData1, $sessionData2) {
8080
if ($id === $uuid1) {
8181
return $sessionData1;
8282
}
@@ -89,7 +89,7 @@ public function testSubscribeAndSendsNotification(): void
8989

9090
$this->sessionFactory->expects($this->exactly(2))
9191
->method('createWithId')
92-
->willReturnCallback(function ($id) use ($uuid1, $uuid2, $session1, $session2) {
92+
->willReturnCallback(static function ($id) use ($uuid1, $uuid2, $session1, $session2) {
9393
if ($id === $uuid1) {
9494
return $session1;
9595
}
@@ -102,7 +102,7 @@ public function testSubscribeAndSendsNotification(): void
102102

103103
$this->protocol->expects($this->exactly(2))
104104
->method('sendNotification')
105-
->with($this->callback(function ($notification) use ($uri) {
105+
->with($this->callback(static function ($notification) use ($uri) {
106106
return $notification instanceof ResourceUpdatedNotification
107107
&& $notification->uri === $uri;
108108
}));
@@ -123,7 +123,7 @@ public function testUnsubscribeRemovesOnlyTargetSession(): void
123123

124124
$callCount = 0;
125125
$session1->expects($this->exactly(2))->method('get')->with('resource_subscriptions', [])
126-
->willReturnCallback(function () use (&$callCount, $uri) {
126+
->willReturnCallback(static function () use (&$callCount, $uri) {
127127
return 0 === $callCount++ ? [] : [$uri => true];
128128
});
129129
$session1->expects($this->exactly(2))->method('set')
@@ -159,7 +159,7 @@ public function testUnsubscribeRemovesOnlyTargetSession(): void
159159

160160
$this->protocol->expects($this->exactly(1))
161161
->method('sendNotification')
162-
->with($this->callback(fn ($notification) => $notification instanceof ResourceUpdatedNotification && $notification->uri === $uri
162+
->with($this->callback(static fn ($notification) => $notification instanceof ResourceUpdatedNotification && $notification->uri === $uri
163163
));
164164

165165
$this->subscriptionManager->notifyResourceChanged($this->protocol, $uri);
@@ -180,7 +180,7 @@ public function testUnsubscribeDoesNotSendNotifications(): void
180180

181181
$callCount = 0;
182182
$session->expects($this->exactly(2))->method('get')->with('resource_subscriptions', [])
183-
->willReturnCallback(function () use (&$callCount, $uri) {
183+
->willReturnCallback(static function () use (&$callCount, $uri) {
184184
return 0 === $callCount++ ? [] : [$uri => true];
185185
});
186186
$session->expects($this->exactly(2))->method('set')

0 commit comments

Comments
 (0)