ForumPostTest.php
2.33 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
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
<?php
namespace FootyRoom\Tests\Unit\ForumPost;
use FootyRoom\Tests\TestCase;
use FootyRoom\Core\ForumPost\ForumPost;
class ForumPostTest extends TestCase
{
/**
* @expectedException \FootyRoom\Core\CoreException
*/
public function testTitleCanNotBeEmpty()
{
$post = new ForumPost(
'',
61,
41301
);
}
public function testConstructor()
{
$title = 'title';
$categoryId = 61;
$userId = 41301;
$post = new ForumPost(
$title,
$categoryId,
$userId
);
$this->assertEquals($title, $post->getTitle());
$this->assertEquals($categoryId, $post->getCategoryId());
$this->assertEquals($userId, $post->getUserId());
$this->assertTrue($post->isPublished());
$this->assertTrue($post->isDiscussionOpen());
return $post;
}
/**
* @depends testConstructor
*/
public function testPublish($post)
{
$post->publish();
$this->assertTrue($post->isPublished());
}
/**
* @depends testConstructor
*/
public function testUnpublish($post)
{
$post->unpublish();
$this->assertFalse($post->isPublished());
}
/**
* @depends testConstructor
*/
public function testOpenDiscussion($post)
{
$post->openDiscussion();
$this->assertTrue($post->isDiscussionOpen());
}
/**
* @depends testConstructor
*/
public function testCloseDiscussion($post)
{
$post->closeDiscussion();
$this->assertFalse($post->isDiscussionOpen());
}
/**
* @depends testConstructor
*/
public function testChangeAuthor($post)
{
$userId = 5555;
$post->changeAuthor($userId);
$this->assertEquals($userId, $post->getUserId());
}
/**
* @depends testConstructor
*/
public function testEditTitle($post)
{
$newTitle = 'Who is the best?';
$post->editTitle($newTitle);
$this->assertEquals($newTitle, $post->getTitle());
}
/**
* @depends testConstructor
*/
public function testSlug($post)
{
$newTitle = 'Who is the best?';
$post->editTitle($newTitle);
$this->assertEquals('who-is-the-best', $post->getSlug());
}
}