[TESTS] Add test for JSON response and invalid accept format

This commit is contained in:
Hugo Sales 2021-08-08 00:40:25 +00:00 committed by Diogo Peralta Cordeiro
parent 66b39d3607
commit ecbfba1b1a
Signed by: diogo
GPG Key ID: 18D2D35001FBFAB0

View File

@ -38,6 +38,16 @@ class ControllerTest extends GNUsocialTestCase
static::assertTrue($response->headers->contains('Content-Type', 'application/json'));
static::assertJson($response->getContent());
$json = json_decode($response->getContent(), associative: true);
dd($json);
static::assertTrue(isset($json['notes']));
static::assertTrue(isset($json['notes'][0]['note']));
static::assertSame($json['notes'][0]['note']['content'], 'some content');
}
public function testUnsupported()
{
$client = static::createClient(options: [], server: ['HTTP_ACCEPT' => 'application/xml']);
$client->request('GET', '/main/all');
// $this->assertResponseStatusCodeSame(406);
$this->assertSelectorTextContains('.stacktrace', 'ClientException');
}
}