Add test for discussion posts being deleted on discussion delete from DB

This commit is contained in:
David Sevilla Martin 2019-10-30 19:27:00 -04:00 committed by Daniël Klabbers
parent d69c4035d9
commit c712d23e9c

View File

@ -27,7 +27,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' => '<t><p>foo bar</p></t>'],
],
'users' => [
$this->adminUser(),
$this->normalUser(),
@ -52,4 +54,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');
}
}