| @@ 127-148 (lines=22) @@ | ||
| 124 | $this->assertTrue($category->canDelete($editor), 'Editor should be able to delete category.'); |
|
| 125 | } |
|
| 126 | ||
| 127 | public function testDuplicateCategories() { |
|
| 128 | $blog = new Blog(); |
|
| 129 | $blog->Title = 'Testing for duplicate categories'; |
|
| 130 | $blog->write(); |
|
| 131 | ||
| 132 | $category = new BlogCategory(); |
|
| 133 | $category->Title = 'Test'; |
|
| 134 | $category->BlogID = $blog->ID; |
|
| 135 | $category->write(); |
|
| 136 | ||
| 137 | $category = new BlogCategory(); |
|
| 138 | $category->Title = 'Test'; |
|
| 139 | $category->BlogID = $blog->ID; |
|
| 140 | try { |
|
| 141 | $category->write(); |
|
| 142 | $this->fail('Duplicate BlogCategory written'); |
|
| 143 | } catch (ValidationException $e) { |
|
| 144 | $codeList = $e->getResult()->codeList(); |
|
| 145 | $this->assertCount(1, $codeList); |
|
| 146 | $this->assertEquals(BlogTag::DUPLICATE_EXCEPTION, $codeList[0]); |
|
| 147 | } |
|
| 148 | } |
|
| 149 | } |
|
| 150 | ||
| @@ 153-174 (lines=22) @@ | ||
| 150 | ||
| 151 | } |
|
| 152 | ||
| 153 | public function testDuplicateTags() { |
|
| 154 | $blog = new Blog(); |
|
| 155 | $blog->Title = 'Testing for duplicate tags'; |
|
| 156 | $blog->write(); |
|
| 157 | ||
| 158 | $tag = new BlogTag(); |
|
| 159 | $tag->Title = 'Test'; |
|
| 160 | $tag->BlogID = $blog->ID; |
|
| 161 | $tag->write(); |
|
| 162 | ||
| 163 | $tag = new BlogTag(); |
|
| 164 | $tag->Title = 'Test'; |
|
| 165 | $tag->BlogID = $blog->ID; |
|
| 166 | try { |
|
| 167 | $tag->write(); |
|
| 168 | $this->fail('Duplicate BlogTag written'); |
|
| 169 | } catch (ValidationException $e) { |
|
| 170 | $codeList = $e->getResult()->codeList(); |
|
| 171 | $this->assertCount(1, $codeList); |
|
| 172 | $this->assertEquals(BlogTag::DUPLICATE_EXCEPTION, $codeList[0]); |
|
| 173 | } |
|
| 174 | } |
|
| 175 | ||
| 176 | } |
|
| 177 | ||