From 4eb3853a69208383e649e73dfea36dce3a93c398 Mon Sep 17 00:00:00 2001 From: Xety Date: Tue, 13 Mar 2018 11:26:55 +0100 Subject: [PATCH] Added PostControllerTest --- .../Discuss/PostControllerTest.php | 39 +++++++++++++++++++ 1 file changed, 39 insertions(+) diff --git a/tests/Http/Controllers/Discuss/PostControllerTest.php b/tests/Http/Controllers/Discuss/PostControllerTest.php index 121c0965..f2c22e5e 100644 --- a/tests/Http/Controllers/Discuss/PostControllerTest.php +++ b/tests/Http/Controllers/Discuss/PostControllerTest.php @@ -100,4 +100,43 @@ public function testAlreadySolvedFailed() $response->assertStatus(302); $response->assertSessionHas('danger'); } + + /** + * testEditSuccess method + * + * @return void + */ + public function testEditSuccess() + { + $data = [ + 'content' => 'This is an edited post.' + ]; + + $response = $this->put('/discuss/post/edit/1', $data); + $response->assertStatus(302); + $response->assertSessionHas('success'); + + $post = DiscussPost::findOrFail(1); + + $this->assertSame($data['content'], $post->content); + } + + /** + * testEditNotAuthorizedFailed method + * + * @return void + */ + public function testEditNotAuthorizedFailed() + { + $user = User::find(3); + $this->be($user); + + $data = [ + 'content' => 'This is an edited post.' + ]; + + $response = $this->put('/discuss/post/edit/1', $data); + $response->assertStatus(302); + $response->assertSessionHas('danger'); + } }