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