silverstripe-comments/tests/CommentAdminTest.php

39 lines
982 B
PHP
Raw Permalink Normal View History

<?php
2016-02-19 01:48:25 +01:00
class CommentAdminTest extends SapphireTest
{
protected $usesDatabase = true;
2016-02-19 01:48:25 +01:00
public function testGetEditForm()
{
$commentAdmin = new CommentAdmin();
$this->logInWithPermission('CMS_ACCESS_CommentAdmin');
2016-02-19 01:48:25 +01:00
$form = $commentAdmin->getEditForm();
$names = $this->getFormFieldNames($form);
$expected = array(
'NewComments',
'ApprovedComments',
'SpamComments'
);
$this->assertEquals($expected, $names);
2016-02-19 01:48:25 +01:00
if ($member = Member::currentUser()) {
$member->logOut();
}
$form = $commentAdmin->getEditForm();
2016-02-19 01:48:25 +01:00
}
2016-02-19 01:48:25 +01:00
private function getFormFieldNames($form)
{
$result = array();
$fields = $form->Fields();
$tab = $fields->findOrMakeTab('Root');
$fields = $tab->FieldList();
foreach ($fields as $field) {
array_push($result, $field->getName());
}
return $result;
}
}