|
@@ 212-250 (lines=39) @@
|
| 209 |
|
/** |
| 210 |
|
* Admin completely deactivated category-chooser |
| 211 |
|
*/ |
| 212 |
|
public function testCategoryChooserDeactivated() { |
| 213 |
|
$Entries = $this->generate('EntriesMock', ['methods' => ['paginate']]); |
| 214 |
|
|
| 215 |
|
Configure::write('Saito.Settings.category_chooser_global', 0); |
| 216 |
|
Configure::write('Saito.Settings.category_chooser_user_override', 0); |
| 217 |
|
|
| 218 |
|
$Entries->expects($this->once()) |
| 219 |
|
->method('paginate') |
| 220 |
|
->will($this->returnValue(array())); |
| 221 |
|
|
| 222 |
|
App::uses('CurrentUserComponent', 'Controller/Component'); |
| 223 |
|
App::uses('ComponentCollection', 'Controller'); |
| 224 |
|
$User = new CurrentUserComponent(new ComponentCollection()); |
| 225 |
|
|
| 226 |
|
$User->Categories = $this->getMock( |
| 227 |
|
'Saito\User\Auth\CategoryAuthorization', |
| 228 |
|
['getAllowed'], |
| 229 |
|
[$User] |
| 230 |
|
); |
| 231 |
|
$User->Categories->expects($this->any()) |
| 232 |
|
->method('getAllowed') |
| 233 |
|
->will($this->returnValue([ |
| 234 |
|
1 => 'Admin', |
| 235 |
|
2 => 'Ontopic', |
| 236 |
|
7 => 'Foo' |
| 237 |
|
] |
| 238 |
|
)); |
| 239 |
|
|
| 240 |
|
$User->setSettings(array( |
| 241 |
|
'id' => 1, |
| 242 |
|
'user_sort_last_answer' => 1, |
| 243 |
|
'user_type' => 'admin', |
| 244 |
|
'user_category_active' => 0, |
| 245 |
|
'user_category_custom' => '', |
| 246 |
|
'user_category_override' => 1, |
| 247 |
|
)); |
| 248 |
|
$Entries->getInitialThreads($User); |
| 249 |
|
$this->assertFalse(isset($Entries->viewVars['categoryChooser'])); |
| 250 |
|
} |
| 251 |
|
|
| 252 |
|
public function testCategoryChooserEmptyCustomSet() { |
| 253 |
|
$Entries = $this->generate('EntriesMock', ['methods' => ['paginate']]); |
|
@@ 252-291 (lines=40) @@
|
| 249 |
|
$this->assertFalse(isset($Entries->viewVars['categoryChooser'])); |
| 250 |
|
} |
| 251 |
|
|
| 252 |
|
public function testCategoryChooserEmptyCustomSet() { |
| 253 |
|
$Entries = $this->generate('EntriesMock', ['methods' => ['paginate']]); |
| 254 |
|
|
| 255 |
|
Configure::write('Saito.Settings.category_chooser_global', 0); |
| 256 |
|
Configure::write('Saito.Settings.category_chooser_user_override', 1); |
| 257 |
|
|
| 258 |
|
$Entries->expects($this->once()) |
| 259 |
|
->method('paginate') |
| 260 |
|
->will($this->returnValue(array())); |
| 261 |
|
|
| 262 |
|
App::uses('CurrentUserComponent', 'Controller/Component'); |
| 263 |
|
App::uses('ComponentCollection', 'Controller'); |
| 264 |
|
$User = new CurrentUserComponent(new ComponentCollection()); |
| 265 |
|
|
| 266 |
|
$User->Categories = $this->getMock( |
| 267 |
|
'Saito\User\Auth\CategoryAuthorization', |
| 268 |
|
['getAllowed'], |
| 269 |
|
[$User] |
| 270 |
|
); |
| 271 |
|
$User->Categories->expects($this->any()) |
| 272 |
|
->method('getAllowed') |
| 273 |
|
->will($this->returnValue([ |
| 274 |
|
1 => 'Admin', |
| 275 |
|
2 => 'Ontopic', |
| 276 |
|
7 => 'Foo' |
| 277 |
|
] |
| 278 |
|
)); |
| 279 |
|
|
| 280 |
|
$User->setSettings(array( |
| 281 |
|
'id' => 1, |
| 282 |
|
'user_sort_last_answer' => 1, |
| 283 |
|
'user_type' => 'admin', |
| 284 |
|
'user_category_active' => 0, |
| 285 |
|
'user_category_custom' => array(), |
| 286 |
|
'user_category_override' => 1, |
| 287 |
|
)); |
| 288 |
|
$Entries->getInitialThreads($User); |
| 289 |
|
$this->assertTrue(isset($Entries->viewVars['categoryChooser'])); |
| 290 |
|
$this->assertEquals($Entries->viewVars['categoryChooserTitleId'], 'All Categories'); |
| 291 |
|
} |
| 292 |
|
|
| 293 |
|
/** |
| 294 |
|
* Test custom set |