| @@ 143-164 (lines=22) @@ | ||
| 140 | $this->assertTrue($category->canDelete($editor), 'Editor should be able to delete category.'); |
|
| 141 | } |
|
| 142 | ||
| 143 | public function testDuplicateCategories() { |
|
| 144 | $blog = new Blog(); |
|
| 145 | $blog->Title = 'Testing for duplicate categories'; |
|
| 146 | $blog->write(); |
|
| 147 | ||
| 148 | $category = new BlogCategory(); |
|
| 149 | $category->Title = 'Test'; |
|
| 150 | $category->BlogID = $blog->ID; |
|
| 151 | $category->write(); |
|
| 152 | ||
| 153 | $category = new BlogCategory(); |
|
| 154 | $category->Title = 'Test'; |
|
| 155 | $category->BlogID = $blog->ID; |
|
| 156 | try { |
|
| 157 | $category->write(); |
|
| 158 | $this->fail('Duplicate BlogCategory written'); |
|
| 159 | } catch (ValidationException $e) { |
|
| 160 | $codeList = $e->getResult()->codeList(); |
|
| 161 | $this->assertCount(1, $codeList); |
|
| 162 | $this->assertEquals(BlogTag::DUPLICATE_EXCEPTION, $codeList[0]); |
|
| 163 | } |
|
| 164 | } |
|
| 165 | } |
|
| 166 | ||
| @@ 169-190 (lines=22) @@ | ||
| 166 | ||
| 167 | } |
|
| 168 | ||
| 169 | public function testDuplicateTags() { |
|
| 170 | $blog = new Blog(); |
|
| 171 | $blog->Title = 'Testing for duplicate tags'; |
|
| 172 | $blog->write(); |
|
| 173 | ||
| 174 | $tag = new BlogTag(); |
|
| 175 | $tag->Title = 'Test'; |
|
| 176 | $tag->BlogID = $blog->ID; |
|
| 177 | $tag->write(); |
|
| 178 | ||
| 179 | $tag = new BlogTag(); |
|
| 180 | $tag->Title = 'Test'; |
|
| 181 | $tag->BlogID = $blog->ID; |
|
| 182 | try { |
|
| 183 | $tag->write(); |
|
| 184 | $this->fail('Duplicate BlogTag written'); |
|
| 185 | } catch (ValidationException $e) { |
|
| 186 | $codeList = $e->getResult()->codeList(); |
|
| 187 | $this->assertCount(1, $codeList); |
|
| 188 | $this->assertEquals(BlogTag::DUPLICATE_EXCEPTION, $codeList[0]); |
|
| 189 | } |
|
| 190 | } |
|
| 191 | ||
| 192 | } |
|
| 193 | ||