public function testRequestHasCorrectDefaultValues() { $request = new Request(); $this->assertFalse($request->isNotification()); $this->assertNull($request->getMethod()); $request->setMethod('test'); $request->setId('1'); $this->assertFalse($request->isNotification()); // explicitly set notification type, but id present // implies: no notification $request->setIsNotification(true); $this->assertFalse($request->isNotification()); $expect = '{"jsonrpc":"2.0","method":"test","id":"1"}'; $this->assertEquals($expect, $request->getRequestBody()); }
public function provideErrorResponses() { $res = array(); $req = new Request(); $req->setId('1'); $res[] = array($req, '{"result":null,"error":{"code":1,"message":"err"},"id":"1"}', '{"code":1,"message":"err"}'); $res[] = array($req, '{"result":null,"error":{"code":2,"message":"err2","data":{"test":"test"}},"id":"1"}', '{"code":2,"message":"err2","data":{"test":"test"}}'); return $res; }