|
@@ 44-80 (lines=37) @@
|
| 41 |
|
// Reset root permission |
| 42 |
|
} |
| 43 |
|
|
| 44 |
|
public function testEditPermissions() |
| 45 |
|
{ |
| 46 |
|
$editor = $this->objFromFixture(Member::class, 'editor'); |
| 47 |
|
|
| 48 |
|
$about = $this->objFromFixture(TestPermissionNode::class, 'about'); |
| 49 |
|
$aboutStaff = $this->objFromFixture(TestPermissionNode::class, 'about-staff'); |
| 50 |
|
$history = $this->objFromFixture(TestPermissionNode::class, 'history'); |
| 51 |
|
$products = $this->objFromFixture(TestPermissionNode::class, 'products'); |
| 52 |
|
$product1 = $this->objFromFixture(TestPermissionNode::class, 'products-product1'); |
| 53 |
|
$product4 = $this->objFromFixture(TestPermissionNode::class, 'products-product4'); |
| 54 |
|
|
| 55 |
|
// Test logged out users cannot edit |
| 56 |
|
Member::actAs(null, function () use ($aboutStaff) { |
| 57 |
|
$this->assertFalse($aboutStaff->canEdit()); |
| 58 |
|
}); |
| 59 |
|
|
| 60 |
|
// Can't edit a page that is locked to admins |
| 61 |
|
$this->assertFalse($about->canEdit($editor)); |
| 62 |
|
|
| 63 |
|
// Can edit a page that is locked to editors |
| 64 |
|
$this->assertTrue($products->canEdit($editor)); |
| 65 |
|
|
| 66 |
|
// Can edit a child of that page that inherits |
| 67 |
|
$this->assertTrue($product1->canEdit($editor)); |
| 68 |
|
|
| 69 |
|
// Can't edit a child of that page that has its permissions overridden |
| 70 |
|
$this->assertFalse($product4->canEdit($editor)); |
| 71 |
|
|
| 72 |
|
// Test that root node respects root permissions |
| 73 |
|
$this->assertTrue($history->canEdit($editor)); |
| 74 |
|
|
| 75 |
|
TestPermissionNode::getInheritedPermissions()->clearCache(); |
| 76 |
|
$this->rootPermissions->setCanEdit(false); |
| 77 |
|
|
| 78 |
|
// With root edit false, permissions are now denied for CanEditType = Inherit |
| 79 |
|
$this->assertFalse($history->canEdit($editor)); |
| 80 |
|
} |
| 81 |
|
|
| 82 |
|
public function testDeletePermissions() |
| 83 |
|
{ |
|
@@ 82-118 (lines=37) @@
|
| 79 |
|
$this->assertFalse($history->canEdit($editor)); |
| 80 |
|
} |
| 81 |
|
|
| 82 |
|
public function testDeletePermissions() |
| 83 |
|
{ |
| 84 |
|
$editor = $this->objFromFixture(Member::class, 'editor'); |
| 85 |
|
|
| 86 |
|
$about = $this->objFromFixture(TestPermissionNode::class, 'about'); |
| 87 |
|
$aboutStaff = $this->objFromFixture(TestPermissionNode::class, 'about-staff'); |
| 88 |
|
$history = $this->objFromFixture(TestPermissionNode::class, 'history'); |
| 89 |
|
$products = $this->objFromFixture(TestPermissionNode::class, 'products'); |
| 90 |
|
$product1 = $this->objFromFixture(TestPermissionNode::class, 'products-product1'); |
| 91 |
|
$product4 = $this->objFromFixture(TestPermissionNode::class, 'products-product4'); |
| 92 |
|
|
| 93 |
|
// Test logged out users cannot edit |
| 94 |
|
Member::actAs(null, function () use ($aboutStaff) { |
| 95 |
|
$this->assertFalse($aboutStaff->canDelete()); |
| 96 |
|
}); |
| 97 |
|
|
| 98 |
|
// Can't edit a page that is locked to admins |
| 99 |
|
$this->assertFalse($about->canDelete($editor)); |
| 100 |
|
|
| 101 |
|
// Can't delete a page if a child (product4) is un-deletable |
| 102 |
|
$this->assertFalse($products->canDelete($editor)); |
| 103 |
|
|
| 104 |
|
// Can edit a child of that page that inherits |
| 105 |
|
$this->assertTrue($product1->canDelete($editor)); |
| 106 |
|
|
| 107 |
|
// Can't edit a child of that page that has its permissions overridden |
| 108 |
|
$this->assertFalse($product4->canDelete($editor)); |
| 109 |
|
|
| 110 |
|
// Test that root node respects root permissions |
| 111 |
|
$this->assertTrue($history->canDelete($editor)); |
| 112 |
|
|
| 113 |
|
TestPermissionNode::getInheritedPermissions()->clearCache(); |
| 114 |
|
$this->rootPermissions->setCanEdit(false); |
| 115 |
|
|
| 116 |
|
// With root edit false, permissions are now denied for CanEditType = Inherit |
| 117 |
|
$this->assertFalse($history->canDelete($editor)); |
| 118 |
|
} |
| 119 |
|
|
| 120 |
|
public function testViewPermissions() |
| 121 |
|
{ |