mirror of
https://github.com/silverstripe/silverstripe-comments
synced 2024-10-22 11:05:49 +02:00
BUGFIX: updated tests and uncommented
This commit is contained in:
parent
30f291fc88
commit
7bb952b826
@ -10,7 +10,7 @@ class CommentsTest extends FunctionalTest {
|
|||||||
function testCanView() {
|
function testCanView() {
|
||||||
$visitor = $this->objFromFixture('Member', 'visitor');
|
$visitor = $this->objFromFixture('Member', 'visitor');
|
||||||
$admin = $this->objFromFixture('Member', 'commentadmin');
|
$admin = $this->objFromFixture('Member', 'commentadmin');
|
||||||
$comment = $this->objFromFixture('PageComment', 'firstComA');
|
$comment = $this->objFromFixture('Comment', 'firstComA');
|
||||||
|
|
||||||
$this->assertTrue($comment->canView($visitor),
|
$this->assertTrue($comment->canView($visitor),
|
||||||
'Unauthenticated members can view comments associated to a page with ProvideComments=1'
|
'Unauthenticated members can view comments associated to a page with ProvideComments=1'
|
||||||
@ -19,7 +19,7 @@ class CommentsTest extends FunctionalTest {
|
|||||||
'Admins with CMS_ACCESS_CommentAdmin permissions can view comments associated to a page with ProvideComments=1'
|
'Admins with CMS_ACCESS_CommentAdmin permissions can view comments associated to a page with ProvideComments=1'
|
||||||
);
|
);
|
||||||
|
|
||||||
$disabledComment = $this->objFromFixture('PageComment', 'disabledCom');
|
$disabledComment = $this->objFromFixture('Comment', 'disabledCom');
|
||||||
|
|
||||||
$this->assertFalse($disabledComment->canView($visitor),
|
$this->assertFalse($disabledComment->canView($visitor),
|
||||||
'Unauthenticated members can not view comments associated to a page with ProvideComments=0'
|
'Unauthenticated members can not view comments associated to a page with ProvideComments=0'
|
||||||
@ -32,7 +32,7 @@ class CommentsTest extends FunctionalTest {
|
|||||||
function testCanEdit() {
|
function testCanEdit() {
|
||||||
$visitor = $this->objFromFixture('Member', 'visitor');
|
$visitor = $this->objFromFixture('Member', 'visitor');
|
||||||
$admin = $this->objFromFixture('Member', 'commentadmin');
|
$admin = $this->objFromFixture('Member', 'commentadmin');
|
||||||
$comment = $this->objFromFixture('PageComment', 'firstComA');
|
$comment = $this->objFromFixture('Comment', 'firstComA');
|
||||||
|
|
||||||
$this->assertFalse($comment->canEdit($visitor));
|
$this->assertFalse($comment->canEdit($visitor));
|
||||||
$this->assertTrue($comment->canEdit($admin));
|
$this->assertTrue($comment->canEdit($admin));
|
||||||
@ -41,7 +41,7 @@ class CommentsTest extends FunctionalTest {
|
|||||||
function testCanDelete() {
|
function testCanDelete() {
|
||||||
$visitor = $this->objFromFixture('Member', 'visitor');
|
$visitor = $this->objFromFixture('Member', 'visitor');
|
||||||
$admin = $this->objFromFixture('Member', 'commentadmin');
|
$admin = $this->objFromFixture('Member', 'commentadmin');
|
||||||
$comment = $this->objFromFixture('PageComment', 'firstComA');
|
$comment = $this->objFromFixture('Comment', 'firstComA');
|
||||||
|
|
||||||
$this->assertFalse($comment->canEdit($visitor));
|
$this->assertFalse($comment->canEdit($visitor));
|
||||||
$this->assertTrue($comment->canEdit($admin));
|
$this->assertTrue($comment->canEdit($admin));
|
||||||
@ -52,38 +52,16 @@ class CommentsTest extends FunctionalTest {
|
|||||||
$this->autoFollowRedirection = false;
|
$this->autoFollowRedirection = false;
|
||||||
$this->logInAs('commentadmin');
|
$this->logInAs('commentadmin');
|
||||||
|
|
||||||
$firstComment = $this->objFromFixture('PageComment', 'firstComA');
|
$firstComment = $this->objFromFixture('Comment', 'firstComA');
|
||||||
$firstCommentID = $firstComment->ID;
|
$firstCommentID = $firstComment->ID;
|
||||||
Director::test($firstPage->RelativeLink(), null, $this->session());
|
Director::test($firstPage->RelativeLink(), null, $this->session());
|
||||||
Director::test('PageComment/deletecomment/'.$firstComment->ID, null, $this->session());
|
$delete = $this->get('CommentingController/delete/'.$firstComment->ID);
|
||||||
|
|
||||||
$this->assertFalse(DataObject::get_by_id('PageComment', $firstCommentID));
|
|
||||||
}
|
|
||||||
|
|
||||||
function testDeleteAllCommentsOnPage() {
|
$this->assertFalse(DataObject::get_by_id('Comment', $firstCommentID));
|
||||||
$second = $this->objFromFixture('Page', 'second');
|
|
||||||
$this->autoFollowRedirection = false;
|
|
||||||
$this->logInAs('commentadmin');
|
|
||||||
|
|
||||||
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() {
|
function testCommenterURLWrite() {
|
||||||
$comment = new PageComment();
|
$comment = new Comment();
|
||||||
// We only care about the CommenterURL, so only set that
|
// We only care about the CommenterURL, so only set that
|
||||||
// Check a http and https URL. Add more test urls here as needed.
|
// Check a http and https URL. Add more test urls here as needed.
|
||||||
$protocols = array(
|
$protocols = array(
|
||||||
|
@ -32,7 +32,7 @@ Page:
|
|||||||
URLSegment: no-comments
|
URLSegment: no-comments
|
||||||
ProvideComments: 0
|
ProvideComments: 0
|
||||||
|
|
||||||
PageComment:
|
Comment:
|
||||||
firstComA:
|
firstComA:
|
||||||
ParentID: =>Page.first
|
ParentID: =>Page.first
|
||||||
Name: FA
|
Name: FA
|
||||||
|
Loading…
Reference in New Issue
Block a user