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