-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Xety
committed
Mar 12, 2018
1 parent
9e3074f
commit 6b7848f
Showing
2 changed files
with
106 additions
and
2 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,103 @@ | ||
<?php | ||
namespace Tests\Http\Controllers\Discuss; | ||
|
||
use Tests\TestCase; | ||
use Xetaravel\Models\DiscussPost; | ||
use Xetaravel\Models\User; | ||
|
||
class PostControllerTest extends TestCase | ||
{ | ||
/** | ||
* Triggered before each test. | ||
* | ||
* @return void | ||
*/ | ||
public function setUp() | ||
{ | ||
parent::setUp(); | ||
|
||
$user = User::find(1); | ||
$this->be($user); | ||
} | ||
|
||
/** | ||
* testCreateSuccess method | ||
* | ||
* @return void | ||
*/ | ||
public function testCreateSuccess() | ||
{ | ||
$data = [ | ||
'conversation_id' => 1, | ||
'content' => '**This** is an awesome text.' | ||
]; | ||
|
||
$response = $this->post('/discuss/post/create', $data); | ||
$response->assertSessionHas('success'); | ||
$response->assertStatus(302); | ||
} | ||
|
||
/** | ||
* testShowSuccess method | ||
* | ||
* @return void | ||
*/ | ||
public function testShowSuccess() | ||
{ | ||
$response = $this->get('/discuss/post/show/2'); | ||
$response->assertStatus(302); | ||
$response->assertRedirect('/discuss/conversation/this-is-an-announcement.1?page=1&#post-2'); | ||
} | ||
|
||
/** | ||
* testDeleteSuccess method | ||
* | ||
* @return void | ||
*/ | ||
public function testDeleteSuccess() | ||
{ | ||
$response = $this->delete('/discuss/post/delete/2'); | ||
$response->assertStatus(302); | ||
$response->assertSessionHas('success'); | ||
|
||
$this->assertNull(DiscussPost::find(2)); | ||
} | ||
|
||
/** | ||
* testDeleteFirstPostFailed method | ||
* | ||
* @return void | ||
*/ | ||
public function testDeleteFirstPostFailed() | ||
{ | ||
$response = $this->delete('/discuss/post/delete/1'); | ||
$response->assertStatus(302); | ||
$response->assertSessionHas('danger'); | ||
} | ||
|
||
/** | ||
* testSolvedSuccess method | ||
* | ||
* @return void | ||
*/ | ||
public function testSolvedSuccess() | ||
{ | ||
$response = $this->get('/discuss/post/solved/2'); | ||
$response->assertStatus(302); | ||
$response->assertSessionHas('success'); | ||
} | ||
|
||
/** | ||
* testAlreadySolvedFailed method | ||
* | ||
* @return void | ||
*/ | ||
public function testAlreadySolvedFailed() | ||
{ | ||
$response = $this->get('/discuss/post/solved/2'); | ||
|
||
$response = $this->get('/discuss/post/solved/2'); | ||
$response->assertStatus(302); | ||
$response->assertSessionHas('danger'); | ||
} | ||
} |