Code Duplication    Length = 19-21 lines in 4 locations

tests/BlogCategoryTest.php 2 locations

@@ 65-85 (lines=21) @@
62
	/**
63
	 * The first blog can be viewed by anybody.
64
	 */
65
	public function testCanEdit() {
66
		$this->useDraftSite();
67
68
		$admin = $this->objFromFixture('Member', 'Admin');
69
		$editor = $this->objFromFixture('Member', 'Editor');
70
71
		$category = $this->objFromFixture('BlogCategory', 'FirstCategory');
72
73
		$this->assertTrue($category->canEdit($admin), 'Admin should be able to edit category.');
74
		$this->assertTrue($category->canEdit($editor), 'Editor should be able to edit category.');
75
76
		$category = $this->objFromFixture('BlogCategory', 'SecondCategory');
77
78
		$this->assertTrue($category->canEdit($admin), 'Admin should be able to edit category.');
79
		$this->assertFalse($category->canEdit($editor), 'Editor should not be able to edit category.');
80
81
		$category = $this->objFromFixture('BlogCategory', 'ThirdCategory');
82
83
		$this->assertTrue($category->canEdit($admin), 'Admin should always be able to edit category.');
84
		$this->assertTrue($category->canEdit($editor), 'Editor should be able to edit category.');
85
	}
86
87
	public function testCanCreate() {
88
		$this->useDraftSite();
@@ 99-117 (lines=19) @@
96
		$this->assertTrue($category->canCreate($editor), 'Editor should be able to create category.');
97
	}
98
99
	public function testCanDelete() {
100
		$this->useDraftSite();
101
102
		$admin = $this->objFromFixture('Member', 'Admin');
103
		$editor = $this->objFromFixture('Member', 'Editor');
104
105
		$category = $this->objFromFixture('BlogCategory', 'FirstCategory');
106
107
		$this->assertTrue($category->canDelete($admin), 'Admin should be able to delete category.');
108
		$this->assertTrue($category->canDelete($editor), 'Editor should be able to category category.');
109
110
		$category = $this->objFromFixture('BlogCategory', 'SecondCategory');
111
		$this->assertTrue($category->canDelete($admin), 'Admin should be able to delete category.');
112
		$this->assertFalse($category->canDelete($editor), 'Editor should not be able to delete category.');
113
114
		$category = $this->objFromFixture('BlogCategory', 'ThirdCategory');
115
		$this->assertTrue($category->canDelete($admin), 'Admin should always be able to delete category.');
116
		$this->assertTrue($category->canDelete($editor), 'Editor should be able to delete category.');
117
	}
118
}
119

tests/BlogTagTest.php 2 locations

@@ 71-91 (lines=21) @@
68
		$this->assertFalse($tag->canView($editor), 'Editor should not be able to view tag.');
69
	}
70
71
	public function testCanEdit() {
72
		$this->useDraftSite();
73
74
		$admin = $this->objFromFixture('Member', 'Admin');
75
		$editor = $this->objFromFixture('Member', 'Editor');
76
77
		$tag = $this->objFromFixture('BlogTag', 'FirstTag');
78
79
		$this->assertTrue($tag->canEdit($admin), 'Admin should be able to edit tag.');
80
		$this->assertTrue($tag->canEdit($editor), 'Editor should be able to edit tag.');
81
82
		$tag = $this->objFromFixture('BlogTag', 'SecondTag');
83
84
		$this->assertTrue($tag->canEdit($admin), 'Admin should be able to edit tag.');
85
		$this->assertFalse($tag->canEdit($editor), 'Editor should not be able to edit tag.');
86
87
		$tag = $this->objFromFixture('BlogTag', 'ThirdTag');
88
89
		$this->assertTrue($tag->canEdit($admin), 'Admin should always be able to edit tags.');
90
		$this->assertTrue($tag->canEdit($editor), 'Editor should be able to edit tag.');
91
	}
92
93
	public function testCanCreate() {
94
		$this->useDraftSite();
@@ 105-125 (lines=21) @@
102
		$this->assertTrue($tag->canCreate($editor), 'Editor should be able to create tag.');
103
	}
104
105
	public function testCanDelete() {
106
		$this->useDraftSite();
107
108
		$admin = $this->objFromFixture('Member', 'Admin');
109
		$editor = $this->objFromFixture('Member', 'Editor');
110
111
		$tag = $this->objFromFixture('BlogTag', 'FirstTag');
112
113
		$this->assertTrue($tag->canDelete($admin), 'Admin should be able to delete tag.');
114
		$this->assertTrue($tag->canDelete($editor), 'Editor should be able to delete tag.');
115
116
		$tag = $this->objFromFixture('BlogTag', 'SecondTag');
117
118
		$this->assertTrue($tag->canDelete($admin), 'Admin should be able to delete tag.');
119
		$this->assertFalse($tag->canDelete($editor), 'Editor should not be able to delete tag.');
120
121
		$tag = $this->objFromFixture('BlogTag', 'ThirdTag');
122
123
		$this->assertTrue($tag->canDelete($admin), 'Admin should always be able to delete tags.');
124
		$this->assertTrue($tag->canDelete($editor), 'Editor should be able to delete tag.');
125
	}
126
}
127