Skip to content

Commit

Permalink
Added PostControllerTest
Browse files Browse the repository at this point in the history
  • Loading branch information
Xety committed Mar 13, 2018
1 parent 6b7848f commit 4eb3853
Showing 1 changed file with 39 additions and 0 deletions.
39 changes: 39 additions & 0 deletions tests/Http/Controllers/Discuss/PostControllerTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -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');
}
}

0 comments on commit 4eb3853

Please sign in to comment.