You are here

public function LdapAuthenticationProfileUpdateFormTest::testForm in Lightweight Directory Access Protocol (LDAP) 8.4

Test the form.

File

ldap_authentication/tests/src/Functional/LdapAuthenticationProfileUpdateFormTest.php, line 50

Class

LdapAuthenticationProfileUpdateFormTest
Test the profile update form.

Namespace

Drupal\Tests\ldap_authentication\Functional

Code

public function testForm() : void {

  // Anon not allowed.
  $this
    ->drupalGet(self::FORM_PATH);
  $this
    ->assertSession()
    ->statusCodeEquals(403);

  // Regular user not allowed.
  $user = $this
    ->drupalCreateUser();
  $this
    ->drupalLogin($user);
  $this
    ->drupalGet(self::FORM_PATH);
  $this
    ->assertSession()
    ->pageTextContains('This form is only available to profiles which need an update.');

  // Regular user not allowed.
  $user = $this
    ->drupalCreateUser([], NULL, FALSE, [
    'mail' => 'tester@invalid.com',
  ]);
  $this
    ->drupalLogin($user);
  $this
    ->drupalGet(self::FORM_PATH);
  $this
    ->assertSession()
    ->pageTextNotContains('This form is only available to profiles which need an update.');
  $edit = [
    'mail' => 'tester2@invalid.com',
  ];
  $this
    ->submitForm($edit, 'op');
  $this
    ->assertSession()
    ->pageTextContains('This email address still matches the invalid email template.');
  $edit = [
    'mail' => 'tester2@valid.com',
  ];
  $this
    ->submitForm($edit, 'op');
  $this
    ->assertSession()
    ->pageTextContains('Your profile has been updated.');
}