You are here

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

File

src/Tests/UiTest.php, line 36

Class

UiTest
Test admin interfaces.

Namespace

Drupal\restrict_by_ip\Tests

Code

public function testUserRegisterSubmit() {
  $form = [];
  $form['name'] = $this
    ->randomMachineName(8);
  $form['mail'] = $this
    ->randomMachineName(5) . '@domain.notatld';
  $pass = $this
    ->randomMachineName(5);
  $form['pass[pass1]'] = $pass;
  $form['pass[pass2]'] = $pass;
  $form['restrict_by_ip_address'] = $this->currentIPCIDR;
  $this
    ->drupalPostForm('admin/people/create', $form, t('Create new account'));
  $user = user_load_by_name($form['name']);
  $this
    ->assertText(t('Created a new user account for @name. No email has been sent.', [
    '@name' => $form['name'],
  ]));
  $this
    ->drupalGet('user/' . $user
    ->id() . '/edit');
  $this
    ->assertFieldByName('restrict_by_ip_address', $form['restrict_by_ip_address']);
}