@@ -409,6 +409,17 @@ public function testIsVersion2(){
409
409
$ this ->assertTrue (Message::createResponseMessageV2 (123 ,'myMethod ' )->isVersion2 ());
410
410
}
411
411
412
+ /**
413
+ * @return void
414
+ * @throws JSONRPCException
415
+ */
416
+ public function testCreateRequestMessageV2WithIdAndMethodAndParamsFalse (){
417
+ $ this ->expectException (JSONRPCException::class);
418
+ $ this ->expectExceptionMessage ('[V2] The "params" property in request MUST be an object, array or null. ' );
419
+
420
+ Message::createRequestMessageV2 (123 ,'abc ' ,false );
421
+ }
422
+
412
423
/**
413
424
* @return void
414
425
* @throws JSONRPCException
@@ -431,6 +442,18 @@ public function testCreateResponseMessageV1WithErrorFalse(){
431
442
Message::createResponseMessageV1 (123 ,null ,false );
432
443
}
433
444
445
+ /**
446
+ * @return void
447
+ * @throws JSONRPCException
448
+ */
449
+ public function testCreateRequestOrNotificationV2 (){
450
+ $ this ->assertInstanceOf (RequestMessage::class,Message::createRequestMessageV2 (123 ,'myMethod ' ,[]));
451
+ $ this ->assertInstanceOf (RequestMessage::class,Message::createRequestMessageV2 (123 ,'myMethod ' ,(object ) []));
452
+
453
+ $ this ->assertInstanceOf (NotificationMessage::class,Message::createNotificationMessageV2 ('myMethod ' ,[]));
454
+ $ this ->assertInstanceOf (NotificationMessage::class,Message::createNotificationMessageV2 ('myMethod ' ,(object ) []));
455
+ }
456
+
434
457
public function testToObject (){
435
458
$ this ->assertEquals ((object ) ['id ' =>123 ,'method ' =>'getMethod ' ,'params ' =>['param1 ' ,'param2 ' ]],Message::createRequestMessageV1 (123 ,'getMethod ' ,['param1 ' ,'param2 ' ])->toObject ());
436
459
}
0 commit comments