@@ 11-56 (lines=46) @@ | ||
8 | static $fixture_file = "forum/tests/ForumTest.yml"; |
|
9 | static $use_draft_site = true; |
|
10 | ||
11 | function testCanView() { |
|
12 | // test viewing not logged in |
|
13 | if($member = Member::currentUser()) $member->logOut(); |
|
14 | ||
15 | $public = $this->objFromFixture('Forum', 'general'); |
|
16 | $private = $this->objFromFixture('Forum', 'loggedInOnly'); |
|
17 | $limited = $this->objFromFixture('Forum', 'limitedToGroup'); |
|
18 | $noposting = $this->objFromFixture('Forum', 'noPostingForum'); |
|
19 | $inherited = $this->objFromFixture('Forum', 'inheritedForum'); |
|
20 | ||
21 | $this->assertTrue($public->canView()); |
|
22 | $this->assertFalse($private->canView()); |
|
23 | $this->assertFalse($limited->canView()); |
|
24 | $this->assertTrue($noposting->canView()); |
|
25 | $this->assertFalse($inherited->canView()); |
|
26 | ||
27 | // try logging in a member |
|
28 | $member = $this->objFromFixture('Member', 'test1'); |
|
29 | $member->logIn(); |
|
30 | ||
31 | $this->assertTrue($public->canView()); |
|
32 | $this->assertTrue($private->canView()); |
|
33 | $this->assertFalse($limited->canView()); |
|
34 | $this->assertTrue($noposting->canView()); |
|
35 | $this->assertFalse($inherited->canView()); |
|
36 | ||
37 | // login as a person with access to restricted forum |
|
38 | $member = $this->objFromFixture('Member', 'test2'); |
|
39 | $member->logIn(); |
|
40 | ||
41 | $this->assertTrue($public->canView()); |
|
42 | $this->assertTrue($private->canView()); |
|
43 | $this->assertTrue($limited->canView()); |
|
44 | $this->assertTrue($noposting->canView()); |
|
45 | $this->assertFalse($inherited->canView()); |
|
46 | ||
47 | // Moderator should be able to view his own forums |
|
48 | $member = $this->objFromFixture('Member', 'moderator'); |
|
49 | $member->logIn(); |
|
50 | ||
51 | $this->assertTrue($public->canView()); |
|
52 | $this->assertTrue($private->canView()); |
|
53 | $this->assertTrue($limited->canView()); |
|
54 | $this->assertTrue($noposting->canView()); |
|
55 | $this->assertTrue($inherited->canView()); |
|
56 | } |
|
57 | ||
58 | function testCanPost() { |
|
59 | // test viewing not logged in |
|
@@ 58-103 (lines=46) @@ | ||
55 | $this->assertTrue($inherited->canView()); |
|
56 | } |
|
57 | ||
58 | function testCanPost() { |
|
59 | // test viewing not logged in |
|
60 | if($member = Member::currentUser()) $member->logOut(); |
|
61 | ||
62 | $public = $this->objFromFixture('Forum', 'general'); |
|
63 | $private = $this->objFromFixture('Forum', 'loggedInOnly'); |
|
64 | $limited = $this->objFromFixture('Forum', 'limitedToGroup'); |
|
65 | $noposting = $this->objFromFixture('Forum', 'noPostingForum'); |
|
66 | $inherited = $this->objFromFixture('Forum', 'inheritedForum'); |
|
67 | ||
68 | $this->assertTrue($public->canPost()); |
|
69 | $this->assertFalse($private->canPost()); |
|
70 | $this->assertFalse($limited->canPost()); |
|
71 | $this->assertFalse($noposting->canPost()); |
|
72 | $this->assertFalse($inherited->canPost()); |
|
73 | ||
74 | // try logging in a member |
|
75 | $member = $this->objFromFixture('Member', 'test1'); |
|
76 | $member->logIn(); |
|
77 | ||
78 | $this->assertTrue($public->canPost()); |
|
79 | $this->assertTrue($private->canPost()); |
|
80 | $this->assertFalse($limited->canPost()); |
|
81 | $this->assertFalse($noposting->canPost()); |
|
82 | $this->assertFalse($inherited->canPost()); |
|
83 | ||
84 | // login as a person with access to restricted forum |
|
85 | $member = $this->objFromFixture('Member', 'test2'); |
|
86 | $member->logIn(); |
|
87 | ||
88 | $this->assertTrue($public->canPost()); |
|
89 | $this->assertTrue($private->canPost()); |
|
90 | $this->assertTrue($limited->canPost()); |
|
91 | $this->assertFalse($noposting->canPost()); |
|
92 | $this->assertFalse($inherited->canPost()); |
|
93 | ||
94 | // Moderator should be able to view his own forums |
|
95 | $member = $this->objFromFixture('Member', 'moderator'); |
|
96 | $member->logIn(); |
|
97 | ||
98 | $this->assertTrue($public->canPost()); |
|
99 | $this->assertTrue($private->canPost()); |
|
100 | $this->assertFalse($limited->canPost()); |
|
101 | $this->assertFalse($noposting->canPost()); |
|
102 | $this->assertFalse($inherited->canPost()); |
|
103 | } |
|
104 | ||
105 | function testSuspended() { |
|
106 | $private = $this->objFromFixture('Forum', 'loggedInOnly'); |
|
@@ 128-173 (lines=46) @@ | ||
125 | $this->assertFalse($inheritedForum_loggedInOnly->canPost()); |
|
126 | } |
|
127 | ||
128 | function testCanModerate() { |
|
129 | // test viewing not logged in |
|
130 | if($member = Member::currentUser()) $member->logOut(); |
|
131 | ||
132 | $public = $this->objFromFixture('Forum', 'general'); |
|
133 | $private = $this->objFromFixture('Forum', 'loggedInOnly'); |
|
134 | $limited = $this->objFromFixture('Forum', 'limitedToGroup'); |
|
135 | $noposting = $this->objFromFixture('Forum', 'noPostingForum'); |
|
136 | $inherited = $this->objFromFixture('Forum', 'inheritedForum'); |
|
137 | ||
138 | $this->assertFalse($public->canModerate()); |
|
139 | $this->assertFalse($private->canModerate()); |
|
140 | $this->assertFalse($limited->canModerate()); |
|
141 | $this->assertFalse($noposting->canModerate()); |
|
142 | $this->assertFalse($inherited->canModerate()); |
|
143 | ||
144 | // try logging in a member |
|
145 | $member = $this->objFromFixture('Member', 'test1'); |
|
146 | $member->logIn(); |
|
147 | ||
148 | $this->assertFalse($public->canModerate()); |
|
149 | $this->assertFalse($private->canModerate()); |
|
150 | $this->assertFalse($limited->canModerate()); |
|
151 | $this->assertFalse($noposting->canModerate()); |
|
152 | $this->assertFalse($inherited->canModerate()); |
|
153 | ||
154 | // login as a person with access to restricted forum |
|
155 | $member = $this->objFromFixture('Member', 'test2'); |
|
156 | $member->logIn(); |
|
157 | ||
158 | $this->assertFalse($public->canModerate()); |
|
159 | $this->assertFalse($private->canModerate()); |
|
160 | $this->assertFalse($limited->canModerate()); |
|
161 | $this->assertFalse($noposting->canModerate()); |
|
162 | $this->assertFalse($inherited->canModerate()); |
|
163 | ||
164 | // Moderator should be able to view his own forums |
|
165 | $member = $this->objFromFixture('Member', 'moderator'); |
|
166 | $member->logIn(); |
|
167 | ||
168 | $this->assertTrue($public->canModerate()); |
|
169 | $this->assertTrue($private->canModerate()); |
|
170 | $this->assertTrue($limited->canModerate()); |
|
171 | $this->assertTrue($noposting->canModerate()); |
|
172 | $this->assertTrue($inherited->canModerate()); |
|
173 | } |
|
174 | ||
175 | function testCanAttach() { |
|
176 | $canAttach = $this->objFromFixture('Forum', 'general'); |