function BetterFormatsTestCase::testBetterFormatsFunctionalTest in Better Formats 6
Same name and namespace in other branches
- 6.2 tests/better_formats_anonymous_user.test \BetterFormatsTestCase::testBetterFormatsFunctionalTest()
Test various behaviors for anonymous users.
File
- tests/
better_formats_anonymous_user.test, line 32 - Tests for the Better Formats module.
Class
- BetterFormatsTestCase
- @file Tests for the Better Formats module.
Code
function testBetterFormatsFunctionalTest() {
// Create a user with permission to view the actions administration pages.
$admin = $this
->drupalCreateUser(array(
'administer permissions',
'administer filters',
));
$this
->drupalLogin($admin);
// Hide the format tips link.
$this
->setPermission('anonymous user', array(
'show more format tips link' => FALSE,
'access comments' => TRUE,
'access content' => TRUE,
'post comments' => TRUE,
'post comments without approval' => TRUE,
));
$this->node = $this
->drupalCreateNode(array(
'type' => 'story',
'promote' => 1,
'comment' => 2,
));
$this
->drupalLogout();
$this
->drupalGet('comment/reply/' . $this->node->nid);
$this
->assertNoText('More information about formatting options.', 'Show more format tips link removed.');
// Default for comments, hiding format selection on comments.
$this
->drupalLogin($admin);
// Let anon use full html - it's crazy, but it's just simpletest
$edit = array();
$edit['roles[1]'] = TRUE;
$this
->drupalPost('admin/settings/filters/2', $edit, t('Save configuration'));
// Set full html as default for anon on comments - again, crazy, but...
$edit = array();
$edit['comment-1[format]'] = 2;
$this
->drupalPost('admin/settings/filters/defaults', $edit, t('Save defaults'));
$this
->setPermission('anonymous user', array(
'show format selection for comments' => FALSE,
'create page content' => TRUE,
));
$this
->drupalLogout();
// Now, do we see the signature for Full HTML on the comment page?
$this
->drupalGet('comment/reply/' . $this->node->nid);
$this
->assertNoText('Allowed HTML tags:', 'Filter tips removed on comments.');
$this
->assertText('Web page addresses and e-mail addresses turn into links automatically.', 'Filter tips removed on comments.');
// And do we see the Filtered HTML on a node page?
$this
->drupalGet('node/add/page');
$this
->assertText('Allowed HTML tags:', 'Filter tips still on a page.');
// Collapsible format selection collapsed by default.
$this
->drupalLogin($admin);
$this
->setPermission('anonymous user', array(
'show format selection for comments' => TRUE,
));
$this
->drupalLogout();
$this
->drupalGet('comment/reply/' . $this->node->nid);
$this
->assertText('Filtered HTML', 'Allow format selection on comments.');
$this
->assertRaw('<fieldset class=" collapsible collapsed"><legend>Input format</legend>', 'Collapsible format selection fieldset found.');
$this
->assertRaw('<input type="radio" id="edit-format-2-1" name="format" value="2" checked="checked" class="form-radio" /> Full HTML', 'Default for comments to Full HTML.');
// Not collapsed by default.
$this
->drupalLogin($admin);
$this
->setPermission('anonymous user', array(
'collapse format fieldset by default' => FALSE,
));
$this
->drupalLogout();
$this
->drupalGet('comment/reply/' . $this->node->nid);
$this
->assertRaw('<fieldset class=" collapsible"><legend>Input format</legend>', 'Collapsible format selection fieldset found.');
// Not even collapsible.
$this
->drupalLogin($admin);
$this
->setPermission('anonymous user', array(
'collapsible format selection' => FALSE,
));
$this
->drupalLogout();
$this
->drupalGet('comment/reply/' . $this->node->nid);
$this
->assertRaw('<fieldset><legend>Input format</legend>', 'Collapsible format selection fieldset found.');
// Check to see that the show format selection on nodes works.
$this
->drupalLogin($admin);
$this
->setPermission('anonymous user', array(
'show format selection for nodes' => FALSE,
));
$this
->drupalLogout();
$this
->drupalGet('node/add/page');
$this
->assertNoRaw('<input type="radio" id="edit-format-1-1" name="format" value="1" checked="checked" class="form-radio" /> Filtered HTML</label>', 'No radios on a page.');
}