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 = '{"method":"test","params":[],"id":"1"}'; $this->assertEquals($expect, $request->getRequestBody()); }
public function provideErrorResponses() { $res = array(); $req = new Request(); $req->setId('1'); $res[] = array($req, '{"result":null,"error":["a"],"id":"1"}', '["a"]'); $res[] = array($req, '{"result":null,"error":"b","id":"1"}', 'b'); $res[] = array($req, '{"result":null,"error":{"a":"b"},"id":"1"}', '{"a":"b"}'); return $res; }