You are here

public function IPBanFormTest::testDisabledBlockEntry in IP Ban 8

Same name and namespace in other branches
  1. 7 ip_ban.test \IPBanFormTest::testDisabledBlockEntry()

Test adding multiple disabled blocks (correct and incorrect).

File

./ip_ban.test, line 163
Tests for ip_ban.module.

Class

IPBanFormTest
Tests the IP Ban admin page form.

Code

public function testDisabledBlockEntry() {

  // Add a valid block.
  $this
    ->drupalGet(IP_BAN_ADMIN_FORM_PATH);
  $edit = array();
  $edit['ip_ban_disabled_blocks'] = 'user,login';
  $this
    ->drupalPost(IP_BAN_ADMIN_FORM_PATH, $edit, t('Save configuration'));
  $this
    ->assertText(t('The configuration options have been saved.'));

  // Use incorrect formatting for the blocks.
  $this
    ->drupalGet(IP_BAN_ADMIN_FORM_PATH);
  $edit = array();
  $edit['ip_ban_disabled_blocks'] = 'user, login block,11';
  $this
    ->drupalPost(IP_BAN_ADMIN_FORM_PATH, $edit, t('Save configuration'));
  $this
    ->assertText(t('You have one or more blocks with an incorrect format; you must enter exactly one module name and delta name per line, separated by a comma.'));

  // Add a block with an incorrect delta.
  $this
    ->drupalGet(IP_BAN_ADMIN_FORM_PATH);
  $edit = array();
  $edit['ip_ban_disabled_blocks'] = 'user,login2';
  $this
    ->drupalPost(IP_BAN_ADMIN_FORM_PATH, $edit, t('Save configuration'));
  $this
    ->assertText(t('You entered at least one invalid module name or delta; see the help text for how to enter the proper module name and delta.'));
}