| @@ 151-175 (lines=25) @@ | ||
| 148 | $this->assertTrue($category->canDelete($editor), 'Editor should be able to delete category.'); |
|
| 149 | } |
|
| 150 | ||
| 151 | public function testDuplicateCategories() |
|
| 152 | { |
|
| 153 | $blog = new Blog(); |
|
| 154 | $blog->Title = 'Testing for duplicate categories'; |
|
| 155 | $blog->write(); |
|
| 156 | ||
| 157 | $category = new BlogCategory(); |
|
| 158 | $category->Title = 'Test'; |
|
| 159 | $category->BlogID = $blog->ID; |
|
| 160 | $category->URLSegment = 'test'; |
|
| 161 | $category->write(); |
|
| 162 | ||
| 163 | $category = new BlogCategory(); |
|
| 164 | $category->Title = 'Test'; |
|
| 165 | $category->URLSegment = 'test'; |
|
| 166 | $category->BlogID = $blog->ID; |
|
| 167 | try { |
|
| 168 | $category->write(); |
|
| 169 | $this->fail('Duplicate BlogCategory written'); |
|
| 170 | } catch (ValidationException $e) { |
|
| 171 | $messages = $e->getResult()->getMessages(); |
|
| 172 | $this->assertCount(1, $messages); |
|
| 173 | $this->assertEquals(BlogTag::DUPLICATE_EXCEPTION, $messages[0]['messageType']); |
|
| 174 | } |
|
| 175 | } |
|
| 176 | } |
|
| 177 | ||
| @@ 177-201 (lines=25) @@ | ||
| 174 | $this->assertEquals('cat-test-1', $tag2->URLSegment); |
|
| 175 | } |
|
| 176 | ||
| 177 | public function testDuplicateTags() |
|
| 178 | { |
|
| 179 | $blog = new Blog(); |
|
| 180 | $blog->Title = 'Testing for duplicate tags'; |
|
| 181 | $blog->write(); |
|
| 182 | ||
| 183 | $tag = new BlogTag(); |
|
| 184 | $tag->Title = 'Test'; |
|
| 185 | $tag->BlogID = $blog->ID; |
|
| 186 | $tag->URLSegment = 'test'; |
|
| 187 | $tag->write(); |
|
| 188 | ||
| 189 | $tag = new BlogTag(); |
|
| 190 | $tag->Title = 'Test'; |
|
| 191 | $tag->URLSegment = 'test'; |
|
| 192 | $tag->BlogID = $blog->ID; |
|
| 193 | try { |
|
| 194 | $tag->write(); |
|
| 195 | $this->fail('Duplicate BlogTag written'); |
|
| 196 | } catch (ValidationException $e) { |
|
| 197 | $messages = $e->getResult()->getMessages(); |
|
| 198 | $this->assertCount(1, $messages); |
|
| 199 | $this->assertEquals(BlogTag::DUPLICATE_EXCEPTION, $messages[0]['messageType']); |
|
| 200 | } |
|
| 201 | } |
|
| 202 | } |
|
| 203 | ||