@@ 155-200 (lines=46) @@ | ||
152 | $this->assertFalse($post->EditLink()); |
|
153 | } |
|
154 | ||
155 | public function testDeleteLink() |
|
156 | { |
|
157 | $post = $this->objFromFixture('Post', 'Post1'); |
|
158 | ||
159 | //enable token |
|
160 | SecurityToken::enable(); |
|
161 | ||
162 | // should be false since we're not logged in. |
|
163 | if ($member = Member::currentUser()) { |
|
164 | $member->logOut(); |
|
165 | } |
|
166 | ||
167 | $this->assertFalse($post->EditLink()); |
|
168 | $this->assertFalse($post->DeleteLink()); |
|
169 | ||
170 | // logged in as the moderator. Should be able to delete the post. |
|
171 | $member = $this->objFromFixture('Member', 'moderator'); |
|
172 | $member->logIn(); |
|
173 | ||
174 | $this->assertContains($post->Thread()->URLSegment .'/deletepost/'. $post->ID, $post->DeleteLink()); |
|
175 | ||
176 | // because this is the first post test for the class which is used in javascript |
|
177 | $this->assertContains("class=\"deleteLink firstPost\"", $post->DeleteLink()); |
|
178 | ||
179 | $member->logOut(); |
|
180 | ||
181 | // log in as another member who is not in a position to delete this post |
|
182 | $member = $this->objFromFixture('Member', 'test2'); |
|
183 | $member->logIn(); |
|
184 | ||
185 | $this->assertFalse($post->DeleteLink()); |
|
186 | ||
187 | // log in as someone who can moderate this post (and therefore delete it) |
|
188 | $member = $this->objFromFixture('Member', 'moderator'); |
|
189 | $member->logIn(); |
|
190 | ||
191 | ||
192 | //check for the existance of a CSRF token |
|
193 | $this->assertContains("SecurityID=", $post->DeleteLink()); |
|
194 | ||
195 | // should be able to edit post since they're moderators |
|
196 | $this->assertContains($post->Thread()->URLSegment .'/deletepost/'. $post->ID, $post->DeleteLink()); |
|
197 | ||
198 | // test that a 2nd post doesn't have the first post ID hook |
|
199 | $memberOthersPost = $this->objFromFixture('Post', 'Post2'); |
|
200 | ||
201 | $this->assertFalse(strstr($memberOthersPost->DeleteLink(), "firstPost")); |
|
202 | } |
|
203 | ||
@@ 204-248 (lines=45) @@ | ||
201 | $this->assertFalse(strstr($memberOthersPost->DeleteLink(), "firstPost")); |
|
202 | } |
|
203 | ||
204 | public function testMarkAsSpamLink() |
|
205 | { |
|
206 | $post = $this->objFromFixture('Post', 'Post1'); |
|
207 | ||
208 | //enable token |
|
209 | SecurityToken::enable(); |
|
210 | ||
211 | // should be false since we're not logged in. |
|
212 | if ($member = Member::currentUser()) { |
|
213 | $member->logOut(); |
|
214 | } |
|
215 | ||
216 | $this->assertFalse($post->EditLink()); |
|
217 | $this->assertFalse($post->MarkAsSpamLink()); |
|
218 | ||
219 | // logged in as the moderator. Should be able to mark the post as spam. |
|
220 | $member = $this->objFromFixture('Member', 'moderator'); |
|
221 | $member->logIn(); |
|
222 | ||
223 | $this->assertContains($post->Thread()->URLSegment .'/markasspam/'. $post->ID, $post->MarkAsSpamLink()); |
|
224 | ||
225 | // because this is the first post test for the class which is used in javascript |
|
226 | $this->assertContains("class=\"markAsSpamLink firstPost\"", $post->MarkAsSpamLink()); |
|
227 | ||
228 | $member->logOut(); |
|
229 | ||
230 | // log in as another member who is not in a position to mark post as spam this post |
|
231 | $member = $this->objFromFixture('Member', 'test2'); |
|
232 | $member->logIn(); |
|
233 | ||
234 | $this->assertFalse($post->MarkAsSpamLink()); |
|
235 | ||
236 | // log in as someone who can moderate this post (and therefore mark as spam) |
|
237 | $member = $this->objFromFixture('Member', 'moderator'); |
|
238 | $member->logIn(); |
|
239 | ||
240 | ||
241 | //check for the existance of a CSRF token |
|
242 | $this->assertContains("SecurityID=", $post->MarkAsSpamLink()); |
|
243 | ||
244 | // should be able to edit post since they're moderators |
|
245 | $this->assertContains($post->Thread()->URLSegment .'/markasspam/'. $post->ID, $post->MarkAsSpamLink()); |
|
246 | ||
247 | // test that a 2nd post doesn't have the first post ID hook |
|
248 | $memberOthersPost = $this->objFromFixture('Post', 'Post2'); |
|
249 | ||
250 | $this->assertFalse(strstr($memberOthersPost->MarkAsSpamLink(), "firstPost")); |
|
251 | } |