From 3526083320e3a634d328938630caa406abccf557 Mon Sep 17 00:00:00 2001 From: David Sevilla Martin Date: Wed, 30 Oct 2019 19:27:00 -0400 Subject: [PATCH] Add test for discussion posts being deleted on discussion delete from DB --- .../DeleteDiscussionControllerTest.php | 16 +++++++++++++++- 1 file changed, 15 insertions(+), 1 deletion(-) diff --git a/tests/integration/api/Controller/DeleteDiscussionControllerTest.php b/tests/integration/api/Controller/DeleteDiscussionControllerTest.php index 1c9df8aba..d2024f50f 100644 --- a/tests/integration/api/Controller/DeleteDiscussionControllerTest.php +++ b/tests/integration/api/Controller/DeleteDiscussionControllerTest.php @@ -25,7 +25,9 @@ class DeleteDiscussionControllerTest extends ApiControllerTestCase 'discussions' => [ ['id' => 1, 'title' => __CLASS__, 'created_at' => Carbon::now()->toDateTimeString(), 'user_id' => 2], ], - 'posts' => [], + 'posts' => [ + ['id' => 1, 'discussion_id' => 1, 'created_at' => Carbon::now()->toDateTimeString(), 'user_id' => 2, 'type' => 'comment', 'content' => '

foo bar

'], + ], 'users' => [ $this->adminUser(), $this->normalUser(), @@ -50,4 +52,16 @@ class DeleteDiscussionControllerTest extends ApiControllerTestCase $this->assertEquals(204, $response->getStatusCode()); } + + /** + * @test + */ + public function deleting_discussions_deletes_their_posts() + { + $this->actor = User::find(1); + + $this->callWith([], ['id' => 1]); + + $this->assertNull($this->database()->table('posts')->find(1), 'Post exists in the DB'); + } }