| @@ 94-114 (lines=21) @@ | ||
| 91 | /** |
|
| 92 | * The first blog can be viewed by anybody. |
|
| 93 | */ |
|
| 94 | public function testCanEdit() |
|
| 95 | { |
|
| 96 | $this->useDraftSite(); |
|
| 97 | ||
| 98 | $admin = $this->objFromFixture('SilverStripe\\Security\\Member', 'Admin'); |
|
| 99 | $editor = $this->objFromFixture('SilverStripe\\Security\\Member', 'Editor'); |
|
| 100 | ||
| 101 | $category = $this->objFromFixture('SilverStripe\\Blog\\Model\\BlogCategory', 'FirstCategory'); |
|
| 102 | ||
| 103 | $this->assertTrue($category->canEdit($admin), 'Admin should be able to edit category.'); |
|
| 104 | $this->assertTrue($category->canEdit($editor), 'Editor should be able to edit category.'); |
|
| 105 | ||
| 106 | $category = $this->objFromFixture('SilverStripe\\Blog\\Model\\BlogCategory', 'SecondCategory'); |
|
| 107 | ||
| 108 | $this->assertTrue($category->canEdit($admin), 'Admin should be able to edit category.'); |
|
| 109 | $this->assertFalse($category->canEdit($editor), 'Editor should not be able to edit category.'); |
|
| 110 | ||
| 111 | $category = $this->objFromFixture('SilverStripe\\Blog\\Model\\BlogCategory', 'ThirdCategory'); |
|
| 112 | ||
| 113 | $this->assertTrue($category->canEdit($admin), 'Admin should always be able to edit category.'); |
|
| 114 | $this->assertTrue($category->canEdit($editor), 'Editor should be able to edit category.'); |
|
| 115 | } |
|
| 116 | ||
| 117 | public function testCanCreate() |
|
| @@ 130-148 (lines=19) @@ | ||
| 127 | $this->assertTrue($category->canCreate($editor), 'Editor should be able to create category.'); |
|
| 128 | } |
|
| 129 | ||
| 130 | public function testCanDelete() |
|
| 131 | { |
|
| 132 | $this->useDraftSite(); |
|
| 133 | ||
| 134 | $admin = $this->objFromFixture('SilverStripe\\Security\\Member', 'Admin'); |
|
| 135 | $editor = $this->objFromFixture('SilverStripe\\Security\\Member', 'Editor'); |
|
| 136 | ||
| 137 | $category = $this->objFromFixture('SilverStripe\\Blog\\Model\\BlogCategory', 'FirstCategory'); |
|
| 138 | ||
| 139 | $this->assertTrue($category->canDelete($admin), 'Admin should be able to delete category.'); |
|
| 140 | $this->assertTrue($category->canDelete($editor), 'Editor should be able to category category.'); |
|
| 141 | ||
| 142 | $category = $this->objFromFixture('SilverStripe\\Blog\\Model\\BlogCategory', 'SecondCategory'); |
|
| 143 | $this->assertTrue($category->canDelete($admin), 'Admin should be able to delete category.'); |
|
| 144 | $this->assertFalse($category->canDelete($editor), 'Editor should not be able to delete category.'); |
|
| 145 | ||
| 146 | $category = $this->objFromFixture('SilverStripe\\Blog\\Model\\BlogCategory', 'ThirdCategory'); |
|
| 147 | $this->assertTrue($category->canDelete($admin), 'Admin should always be able to delete category.'); |
|
| 148 | $this->assertTrue($category->canDelete($editor), 'Editor should be able to delete category.'); |
|
| 149 | } |
|
| 150 | ||
| 151 | public function testDuplicateCategories() |
|
| @@ 100-120 (lines=21) @@ | ||
| 97 | $this->assertFalse($tag->canView($editor), 'Editor should not be able to view tag.'); |
|
| 98 | } |
|
| 99 | ||
| 100 | public function testCanEdit() |
|
| 101 | { |
|
| 102 | $this->useDraftSite(); |
|
| 103 | ||
| 104 | $admin = $this->objFromFixture('SilverStripe\\Security\\Member', 'Admin'); |
|
| 105 | $editor = $this->objFromFixture('SilverStripe\\Security\\Member', 'Editor'); |
|
| 106 | ||
| 107 | $tag = $this->objFromFixture('SilverStripe\\Blog\\Model\\BlogTag', 'FirstTag'); |
|
| 108 | ||
| 109 | $this->assertTrue($tag->canEdit($admin), 'Admin should be able to edit tag.'); |
|
| 110 | $this->assertTrue($tag->canEdit($editor), 'Editor should be able to edit tag.'); |
|
| 111 | ||
| 112 | $tag = $this->objFromFixture('SilverStripe\\Blog\\Model\\BlogTag', 'SecondTag'); |
|
| 113 | ||
| 114 | $this->assertTrue($tag->canEdit($admin), 'Admin should be able to edit tag.'); |
|
| 115 | $this->assertFalse($tag->canEdit($editor), 'Editor should not be able to edit tag.'); |
|
| 116 | ||
| 117 | $tag = $this->objFromFixture('SilverStripe\\Blog\\Model\\BlogTag', 'ThirdTag'); |
|
| 118 | ||
| 119 | $this->assertTrue($tag->canEdit($admin), 'Admin should always be able to edit tags.'); |
|
| 120 | $this->assertTrue($tag->canEdit($editor), 'Editor should be able to edit tag.'); |
|
| 121 | } |
|
| 122 | ||
| 123 | public function testCanCreate() |
|
| @@ 136-156 (lines=21) @@ | ||
| 133 | $this->assertTrue($tag->canCreate($editor), 'Editor should be able to create tag.'); |
|
| 134 | } |
|
| 135 | ||
| 136 | public function testCanDelete() |
|
| 137 | { |
|
| 138 | $this->useDraftSite(); |
|
| 139 | ||
| 140 | $admin = $this->objFromFixture('SilverStripe\\Security\\Member', 'Admin'); |
|
| 141 | $editor = $this->objFromFixture('SilverStripe\\Security\\Member', 'Editor'); |
|
| 142 | ||
| 143 | $tag = $this->objFromFixture('SilverStripe\\Blog\\Model\\BlogTag', 'FirstTag'); |
|
| 144 | ||
| 145 | $this->assertTrue($tag->canDelete($admin), 'Admin should be able to delete tag.'); |
|
| 146 | $this->assertTrue($tag->canDelete($editor), 'Editor should be able to delete tag.'); |
|
| 147 | ||
| 148 | $tag = $this->objFromFixture('SilverStripe\\Blog\\Model\\BlogTag', 'SecondTag'); |
|
| 149 | ||
| 150 | $this->assertTrue($tag->canDelete($admin), 'Admin should be able to delete tag.'); |
|
| 151 | $this->assertFalse($tag->canDelete($editor), 'Editor should not be able to delete tag.'); |
|
| 152 | ||
| 153 | $tag = $this->objFromFixture('SilverStripe\\Blog\\Model\\BlogTag', 'ThirdTag'); |
|
| 154 | ||
| 155 | $this->assertTrue($tag->canDelete($admin), 'Admin should always be able to delete tags.'); |
|
| 156 | $this->assertTrue($tag->canDelete($editor), 'Editor should be able to delete tag.'); |
|
| 157 | } |
|
| 158 | ||
| 159 | public function testDuplicateTagsForURLSegment() |
|