silverstripe-reports/tests/PageCommentsTest.php
Ingo Schommer 0b6f99df14 BUGFIX: Comment URL field check is now case insenstive. Included tests for various protocols. PATCH via simon_w. Ticket #4776 (from r97016)
git-svn-id: svn://svn.silverstripe.com/silverstripe/open/modules/cms/trunk@102706 467b73ca-7a2a-4603-9d3b-597d59a354a9
2010-04-13 06:59:20 +00:00

48 lines
1.5 KiB
PHP

<?php
class PageCommentsTest extends FunctionalTest {
static $fixture_file = 'cms/tests/PageCommentsTest.yml';
function testDeleteAllCommentsOnPage() {
$second = $this->objFromFixture('Page', 'second');
$this->autoFollowRedirection = false;
$this->logInAs('admin');
Director::test('second-page', null, $this->session());
Director::test('PageComment/deleteallcomments?pageid='.$second->ID,
null, $this->session());
Director::test('second-page', null, $this->session());
$secondComments = DataObject::get('PageComment', 'ParentID = '.$second->ID);
$this->assertNull($secondComments);
$first = $this->objFromFixture('Page', 'first');
$firstComments = DataObject::get('PageComment', 'ParentID = '.$first->ID);
$this->assertNotNull($firstComments);
$third = $this->objFromFixture('Page', 'third');
$thirdComments = DataObject::get('PageComment', 'ParentID = '.$third->ID);
$this->assertEquals($thirdComments->Count(), 3);
}
function testCommenterURLWrite() {
$comment = new PageComment();
// We only care about the CommenterURL, so only set that
// Check a http and https URL. Add more test urls here as needed.
$protocols = array(
'Http',
'Https',
);
$url = '://example.com';
foreach($protocols as $protocol) {
$comment->CommenterURL = $protocol . $url;
// The protocol should stay as if, assuming it is valid
$comment->write();
$this->assertEquals($comment->CommenterURL, $protocol . $url, $protocol . ':// is a valid protocol');
}
}
}