GetCommentTest.php
1.74 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
<?php
namespace FootyRoom\Tests;
class GetCommentTest extends TestCase
{
use SetsUpFixtures;
public function testGuestCanGetComment()
{
$response = $this->json('GET', '/comments/1');
$this->assertEquals(200, $response->status());
$this->assertObjectHaveAttributes(
['id', 'author', 'content', 'html', 'date', 'approved', 'userId', 'karma', 'parentId', 'teamname', 'meta', 'userInfo', 'replies', 'discussionId'],
$response->original['comment']
);
$this->assertEmpty($response->original['comment']->meta);
}
public function testLoggedInCanGetComment()
{
$user = factory('FootyRoom\User\User')->make(['user_id' => 2]);
$response = $this->actingAs($user)->json('GET', '/comments/1');
$this->assertEquals(200, $response->status());
$this->assertObjectHaveAttributes(
['id', 'author', 'content', 'html', 'date', 'approved', 'userId', 'karma', 'parentId', 'teamname', 'meta', 'userInfo', 'replies', 'discussionId'],
$response->original['comment']
);
}
public function testCommentNotFoundShouldBeNull()
{
$response = $this->json('GET', '/comments/9999');
$this->assertEquals(200, $response->status());
$this->assertNull($response->original['comment']);
}
public function testCommentFoundHaveCorrectFormat()
{
$response = $this->json('GET', '/comments/1');
$this->assertEquals(200, $response->status());
$this->assertObjectHaveAttributes(
['id', 'author', 'content', 'html', 'date', 'approved', 'userId', 'karma', 'parentId', 'teamname', 'meta', 'userInfo', 'replies', 'discussionId'],
$response->original['comment']
);
}
}