From c24c32334d84a82de0a8a981e9fe3cf299c42f80 Mon Sep 17 00:00:00 2001 From: Hugo Sales Date: Sun, 8 Aug 2021 00:40:25 +0000 Subject: [PATCH] [TESTS] Add test for JSON response and invalid accept format --- tests/Core/ControllerTest.php | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/tests/Core/ControllerTest.php b/tests/Core/ControllerTest.php index 1d34550a76..5a4852ecf0 100644 --- a/tests/Core/ControllerTest.php +++ b/tests/Core/ControllerTest.php @@ -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'); } }