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