You are here

public function UiTest::testAdminEditUserValidation in Restrict Login or Role Access by IP Address 8.4

File

src/Tests/UiTest.php, line 101

Class

UiTest
Test admin interfaces.

Namespace

Drupal\restrict_by_ip\Tests

Code

public function testAdminEditUserValidation() {

  // First add a user.
  $user = $this
    ->drupalCreateUser();
  $form = [];
  $form['name'] = $user
    ->label() . ' (' . $user
    ->id() . ')';
  $form['restriction'] = $this->currentIPCIDR;
  $this
    ->drupalPostForm('admin/config/people/restrict_by_ip/login/user', $form, t('Save configuration'));
  $this
    ->assertText('The configuration options have been saved.');
  $this
    ->assertFieldByName('restrict_by_ip_user_' . $user
    ->id(), $form['restriction']);

  // Then update it's IP.
  $form = [];
  $form['restrict_by_ip_user_' . $user
    ->id()] = 'not_an_ip';
  $this
    ->drupalPostForm('admin/config/people/restrict_by_ip/login/user', $form, t('Save configuration'));
  $this
    ->assertText('IP address must be in CIDR notation.');
}