PostFlagDataTest.php
1.44 KB
<?php
namespace FootyRoom\Tests;
class PostFlagDataTest extends TestCase
{
use SetsUpFixtures;
public function testGuestForbiddenToFlag()
{
$response = $this->json('POST', '/comments/1/flag');
$this->assertEquals(403, $response->status());
$this->assertContains('You need to be logged in to use this feature.', $response->getContent());
}
public function testEmptyFlagNameShouldThrowException()
{
$user = factory('FootyRoom\User\User')->make(['user_id' => 2]);
$response = $this->actingAs($user)->json('POST', '/comments/1/flag');
$this->assertEquals(400, $response->status());
$this->assertContains('Flag name must not be empty', $response->getContent());
$user = factory('FootyRoom\User\User')->make(['user_id' => 2]);
$response = $this->actingAs($user)->json('POST', '/comments/1/flag', ['flagname' => '']);
$this->assertEquals(400, $response->status());
$this->assertContains('Flag name must not be empty', $response->getContent());
}
public function testCommentNotFoundShouldThrowException()
{
$user = factory('FootyRoom\User\User')->make(['user_id' => 2]);
$response = $this->actingAs($user)->json('POST', '/comments/7878/flag', ['flagName' => 'rude']);
$this->assertEquals(400, $response->status());
$this->assertContains('The comment you are trying to flag is gone.', $response->getContent());
}
}