public function testShouldBuildAnErrorResponse() { $item = new \stdClass(); $item->firstname = 'john'; $builder = ResponseBuilder::create('1.2', HttpMethod::GET()); $builder->addParameter(Parameter::create('id', '42'))->addItem($item)->addError(Error::create('error message 1', 'reason1'))->addError(Error::create('error message 2', 'reason2', 'location2'))->setHttpErrorCode(HttpErrorCode::code402()); $this->assertSame('{"apiVersion":"1.2","method":"GET","params":{"id":"42"},"code":402,"message":"error message 1","errors":[{"message":"error message 1","reason":"reason1","location":""},{"message":"error message 2","reason":"reason2","location":"location2"}]}', json_encode($builder->build())); }
public function testShouldHaveACODE_402() { $this->assertSame(HttpErrorCode::CODE_402, HttpErrorCode::code402()->getValue()); }