File tree Expand file tree Collapse file tree 2 files changed +37
-1
lines changed Expand file tree Collapse file tree 2 files changed +37
-1
lines changed Original file line number Diff line number Diff line change @@ -43,7 +43,7 @@ public static function make(EventDispatcher $eventDispatcher): self
4343 return $ instance ;
4444 }
4545
46- public function onEvent (object $ event ): void
46+ public function onEvent (Event $ event ): void
4747 {
4848 $ eventClass = $ event ::class;
4949 if (!isset (self ::EVENTS_TO_NOTIFICATIONS [$ eventClass ])) {
Original file line number Diff line number Diff line change 1+ <?php
2+
3+ declare (strict_types=1 );
4+
5+ namespace Mcp \Tests \Server ;
6+
7+ use Mcp \JsonRpc \MessageFactory ;
8+ use Mcp \Server \NotificationPublisher ;
9+ use PHPUnit \Framework \TestCase ;
10+ use Symfony \Contracts \EventDispatcher \Event ;
11+
12+ class NotificationPublisherTest extends TestCase
13+ {
14+ public function testOnEventCreatesNotification (): void
15+ {
16+ $ expectedNotifications = [];
17+ $ notificationPublisher = new NotificationPublisher (MessageFactory::make ());
18+
19+ foreach (NotificationPublisher::EVENTS_TO_NOTIFICATIONS as $ eventClass => $ notificationClass ) {
20+ /** @var Event $event */
21+ $ event = new $ eventClass ();
22+ $ notificationPublisher ->onEvent ($ event );
23+ $ expectedNotifications [] = $ notificationClass ;
24+ }
25+
26+ $ flushedNotifications = $ notificationPublisher ->flush ();
27+
28+ $ this ->assertCount (count ($ expectedNotifications ), $ flushedNotifications );
29+
30+ foreach ($ flushedNotifications as $ index => $ notification ) {
31+ $ this ->assertInstanceOf ($ expectedNotifications [$ index ], $ notification );
32+ }
33+
34+ $ this ->assertEmpty ($ notificationPublisher ->flush ());
35+ }
36+ }
You can’t perform that action at this time.
0 commit comments