| @@ 103-130 (lines=28) @@ | ||
| 100 | /** |
|
| 101 | * The first blog can be viewed by anybody. |
|
| 102 | */ |
|
| 103 | public function testCanEdit() |
|
| 104 | { |
|
| 105 | $this->useDraftSite(); |
|
| 106 | ||
| 107 | $admin = $this->objFromFixture(Member::class, 'Admin'); |
|
| 108 | $editor = $this->objFromFixture(Member::class, 'Editor'); |
|
| 109 | ||
| 110 | /** @var Blog $firstBlog */ |
|
| 111 | $firstBlog = $this->objFromFixture(Blog::class, 'FirstBlog'); |
|
| 112 | $firstCategory = $firstBlog->Categories(false)->find('URLSegment', 'first-category'); |
|
| 113 | ||
| 114 | $this->assertTrue($firstCategory->canEdit($admin), 'Admin should be able to edit category.'); |
|
| 115 | $this->assertTrue($firstCategory->canEdit($editor), 'Editor should be able to edit category.'); |
|
| 116 | ||
| 117 | /** @var Blog $secondBlog */ |
|
| 118 | $secondBlog = $this->objFromFixture(Blog::class, 'SecondBlog'); |
|
| 119 | $secondCategory = $secondBlog->Categories(false)->find('URLSegment', 'second-category'); |
|
| 120 | ||
| 121 | $this->assertTrue($secondCategory->canEdit($admin), 'Admin should be able to edit category.'); |
|
| 122 | $this->assertFalse($secondCategory->canEdit($editor), 'Editor should not be able to edit category.'); |
|
| 123 | ||
| 124 | /** @var Blog $secondBlog */ |
|
| 125 | $thirdBlog = $this->objFromFixture(Blog::class, 'ThirdBlog'); |
|
| 126 | $thirdCategory = $thirdBlog->Categories(false)->find('URLSegment', 'third-category'); |
|
| 127 | ||
| 128 | $this->assertTrue($thirdCategory->canEdit($admin), 'Admin should always be able to edit category.'); |
|
| 129 | $this->assertTrue($thirdCategory->canEdit($editor), 'Editor should be able to edit category.'); |
|
| 130 | } |
|
| 131 | ||
| 132 | public function testCanCreate() |
|
| 133 | { |
|
| @@ 145-172 (lines=28) @@ | ||
| 142 | $this->assertTrue($category->canCreate($editor), 'Editor should be able to create category.'); |
|
| 143 | } |
|
| 144 | ||
| 145 | public function testCanDelete() |
|
| 146 | { |
|
| 147 | $this->useDraftSite(); |
|
| 148 | ||
| 149 | $admin = $this->objFromFixture(Member::class, 'Admin'); |
|
| 150 | $editor = $this->objFromFixture(Member::class, 'Editor'); |
|
| 151 | ||
| 152 | /** @var Blog $firstBlog */ |
|
| 153 | $firstBlog = $this->objFromFixture(Blog::class, 'FirstBlog'); |
|
| 154 | $firstCategory = $firstBlog->Categories(false)->find('URLSegment', 'first-category'); |
|
| 155 | ||
| 156 | $this->assertTrue($firstCategory->canDelete($admin), 'Admin should be able to delete category.'); |
|
| 157 | $this->assertTrue($firstCategory->canDelete($editor), 'Editor should be able to category category.'); |
|
| 158 | ||
| 159 | /** @var Blog $secondBlog */ |
|
| 160 | $secondBlog = $this->objFromFixture(Blog::class, 'SecondBlog'); |
|
| 161 | $secondCategory = $secondBlog->Categories(false)->find('URLSegment', 'second-category'); |
|
| 162 | ||
| 163 | $this->assertTrue($secondCategory->canDelete($admin), 'Admin should be able to delete category.'); |
|
| 164 | $this->assertFalse($secondCategory->canDelete($editor), 'Editor should not be able to delete category.'); |
|
| 165 | ||
| 166 | /** @var Blog $secondBlog */ |
|
| 167 | $thirdBlog = $this->objFromFixture(Blog::class, 'ThirdBlog'); |
|
| 168 | $thirdCategory = $thirdBlog->Categories(false)->find('URLSegment', 'third-category'); |
|
| 169 | ||
| 170 | $this->assertTrue($thirdCategory->canDelete($admin), 'Admin should always be able to delete category.'); |
|
| 171 | $this->assertTrue($thirdCategory->canDelete($editor), 'Editor should be able to delete category.'); |
|
| 172 | } |
|
| 173 | ||
| 174 | public function testDuplicateCategories() |
|
| 175 | { |
|
| @@ 101-128 (lines=28) @@ | ||
| 98 | $this->assertFalse($secondTag->canView($editor), 'Editor should not be able to view tag.'); |
|
| 99 | } |
|
| 100 | ||
| 101 | public function testCanEdit() |
|
| 102 | { |
|
| 103 | $this->useDraftSite(); |
|
| 104 | ||
| 105 | $admin = $this->objFromFixture(Member::class, 'Admin'); |
|
| 106 | $editor = $this->objFromFixture(Member::class, 'Editor'); |
|
| 107 | ||
| 108 | /** @var Blog $firstBlog */ |
|
| 109 | $firstBlog = $this->objFromFixture(Blog::class, 'FirstBlog'); |
|
| 110 | $firstTag = $firstBlog->Tags(false)->find('URLSegment', 'first-tag'); |
|
| 111 | ||
| 112 | $this->assertTrue($firstTag->canEdit($admin), 'Admin should be able to edit tag.'); |
|
| 113 | $this->assertTrue($firstTag->canEdit($editor), 'Editor should be able to edit tag.'); |
|
| 114 | ||
| 115 | /** @var Blog $secondBlog */ |
|
| 116 | $secondBlog = $this->objFromFixture(Blog::class, 'SecondBlog'); |
|
| 117 | $secondTag = $secondBlog->Tags(false)->find('URLSegment', 'second-tag'); |
|
| 118 | ||
| 119 | $this->assertTrue($secondTag->canEdit($admin), 'Admin should be able to edit tag.'); |
|
| 120 | $this->assertFalse($secondTag->canEdit($editor), 'Editor should not be able to edit tag.'); |
|
| 121 | ||
| 122 | /** @var Blog $thirdBlog */ |
|
| 123 | $thirdBlog = $this->objFromFixture(Blog::class, 'ThirdBlog'); |
|
| 124 | $thirdTag = $thirdBlog->Tags(false)->find('URLSegment', 'third-tag'); |
|
| 125 | ||
| 126 | $this->assertTrue($thirdTag->canEdit($admin), 'Admin should always be able to edit tags.'); |
|
| 127 | $this->assertTrue($thirdTag->canEdit($editor), 'Editor should be able to edit tag.'); |
|
| 128 | } |
|
| 129 | ||
| 130 | public function testCanCreate() |
|
| 131 | { |
|
| @@ 143-170 (lines=28) @@ | ||
| 140 | $this->assertTrue($tag->canCreate($editor), 'Editor should be able to create tag.'); |
|
| 141 | } |
|
| 142 | ||
| 143 | public function testCanDelete() |
|
| 144 | { |
|
| 145 | $this->useDraftSite(); |
|
| 146 | ||
| 147 | $admin = $this->objFromFixture(Member::class, 'Admin'); |
|
| 148 | $editor = $this->objFromFixture(Member::class, 'Editor'); |
|
| 149 | ||
| 150 | /** @var Blog $firstBlog */ |
|
| 151 | $firstBlog = $this->objFromFixture(Blog::class, 'FirstBlog'); |
|
| 152 | $firstTag = $firstBlog->Tags(false)->find('URLSegment', 'first-tag'); |
|
| 153 | ||
| 154 | $this->assertTrue($firstTag->canDelete($admin), 'Admin should be able to delete tag.'); |
|
| 155 | $this->assertTrue($firstTag->canDelete($editor), 'Editor should be able to delete tag.'); |
|
| 156 | ||
| 157 | /** @var Blog $secondBlog */ |
|
| 158 | $secondBlog = $this->objFromFixture(Blog::class, 'SecondBlog'); |
|
| 159 | $secondTag = $secondBlog->Tags(false)->find('URLSegment', 'second-tag'); |
|
| 160 | ||
| 161 | $this->assertTrue($secondTag->canDelete($admin), 'Admin should be able to delete tag.'); |
|
| 162 | $this->assertFalse($secondTag->canDelete($editor), 'Editor should not be able to delete tag.'); |
|
| 163 | ||
| 164 | /** @var Blog $thirdBlog */ |
|
| 165 | $thirdBlog = $this->objFromFixture(Blog::class, 'ThirdBlog'); |
|
| 166 | $thirdTag = $thirdBlog->Tags(false)->find('URLSegment', 'third-tag'); |
|
| 167 | ||
| 168 | $this->assertTrue($thirdTag->canDelete($admin), 'Admin should always be able to delete tags.'); |
|
| 169 | $this->assertTrue($thirdTag->canDelete($editor), 'Editor should be able to delete tag.'); |
|
| 170 | } |
|
| 171 | ||
| 172 | public function testDuplicateTagsForURLSegment() |
|
| 173 | { |
|