Ejemplo n.º 1
0
    public function testRenderingFullProblem()
    {
        $expectedBody = <<<JSON
{
    "status": 500,
    "title": "Application error code 5021",
    "type": "http://example/problem1.html",
    "detail": "Major Tom, are you receiving me?",
    "instance": "http://example/issue/12345.html",
    "ext1": "data1",
    "ext2": "data2",
    "ext3": "data3"
}
JSON;
        $problem = new HTTPProblem(500, 'Major Tom, are you receiving me?', ['ext1' => 'data1', 'ext2' => 'data2', 'ext3' => 'data3']);
        $problem->withTitle('Application error code 5021')->withType('http://example/problem1.html')->withInstance('http://example/issue/12345.html');
        $renderer = new JSONRenderer();
        $body = $renderer->body($problem);
        $this->assertSame($expectedBody, $body);
    }