diff --git a/framework/core/tests/integration/api/discussions/CreateTest.php b/framework/core/tests/integration/api/discussions/CreateTest.php index d306bc99b5..a8a03e7d28 100644 --- a/framework/core/tests/integration/api/discussions/CreateTest.php +++ b/framework/core/tests/integration/api/discussions/CreateTest.php @@ -68,6 +68,75 @@ public function cannot_create_discussion_without_content() ], json_decode($body, true)); } + /** + * @test + */ + public function cannot_create_discussion_without_content_property() + { + $response = $this->send( + $this->request('POST', '/api/discussions', [ + 'authenticatedAs' => 1, + 'json' => [ + 'data' => [ + 'attributes' => [ + 'title' => 'Test post', + ], + ], + ], + ]) + ); + + $this->assertEquals(422, $response->getStatusCode()); + + $body = (string) $response->getBody(); + $this->assertJson($body); + $this->assertEquals([ + 'errors' => [ + [ + 'status' => '422', + 'code' => 'validation_error', + 'detail' => 'The content field is required.', + 'source' => ['pointer' => '/data/attributes/content'], + ], + ], + ], json_decode($body, true)); + } + + /** + * @test + */ + public function cannot_create_discussion_with_content_set_to_null() + { + $response = $this->send( + $this->request('POST', '/api/discussions', [ + 'authenticatedAs' => 1, + 'json' => [ + 'data' => [ + 'attributes' => [ + 'title' => 'Test post', + 'content' => null, + ], + ], + ], + ]) + ); + + $this->assertEquals(422, $response->getStatusCode()); + + $body = (string) $response->getBody(); + $this->assertJson($body); + $this->assertEquals([ + 'errors' => [ + [ + 'status' => '422', + 'code' => 'validation_error', + 'detail' => 'The content field is required.', + 'source' => ['pointer' => '/data/attributes/content'], + ], + ], + ], json_decode($body, true)); + } + /** * @test */