Skip to content

Commit 9075d55

Browse files
committed
Add more tests
1 parent 7d62e48 commit 9075d55

File tree

1 file changed

+44
-0
lines changed

1 file changed

+44
-0
lines changed

tests/MessageTest.php

Lines changed: 44 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -128,6 +128,50 @@ public function testParseEmptyObject(){
128128
Message::parseObject((object) []);
129129
}
130130

131+
/**
132+
* @return void
133+
* @throws JSONRPCException
134+
*/
135+
public function testParseRequestV1WithMethod(){
136+
$this->expectException(JSONRPCException::class);
137+
$this->expectExceptionMessage('[V1] The "method" property in request MUST be a string.');
138+
139+
Message::parseObject((object) ['method'=>null]);
140+
}
141+
142+
/**
143+
* @return void
144+
* @throws JSONRPCException
145+
*/
146+
public function testParseRequestV1WithParams(){
147+
$this->expectException(JSONRPCException::class);
148+
$this->expectExceptionMessage('[V1] Missing "method" property in request.');
149+
150+
Message::parseObject((object) ['params'=>null]);
151+
}
152+
153+
/**
154+
* @return void
155+
* @throws JSONRPCException
156+
*/
157+
public function testParseResponseV1WithResult(){
158+
$this->expectException(JSONRPCException::class);
159+
$this->expectExceptionMessage('[V1] Missing "error" property in request.');
160+
161+
Message::parseObject((object) ['result'=>null]);
162+
}
163+
164+
/**
165+
* @return void
166+
* @throws JSONRPCException
167+
*/
168+
public function testParseResponseV1WithError(){
169+
$this->expectException(JSONRPCException::class);
170+
$this->expectExceptionMessage('[V1] Missing "result" property in request.');
171+
172+
Message::parseObject((object) ['error'=>null]);
173+
}
174+
131175
/**
132176
* @return void
133177
* @throws JSONRPCException

0 commit comments

Comments
 (0)