LdapAuthenticationProfileUpdateFormTest.php in Lightweight Directory Access Protocol (LDAP) 8.4
File
ldap_authentication/tests/src/Functional/LdapAuthenticationProfileUpdateFormTest.php
View source
<?php
declare (strict_types=1);
namespace Drupal\Tests\ldap_authentication\Functional;
use Drupal\Tests\BrowserTestBase;
class LdapAuthenticationProfileUpdateFormTest extends BrowserTestBase {
protected $defaultTheme = 'stark';
protected const FORM_PATH = '/user/ldap-profile-update';
protected static $modules = [
'system',
'ldap_authentication',
'ldap_servers',
'externalauth',
'ldap_user',
'ldap_query',
];
public function setUp() : void {
parent::setUp();
$this
->config('ldap_authentication.settings')
->set('emailTemplateUsagePromptRegex', '.*@invalid\\.com')
->save();
}
public function testForm() : void {
$this
->drupalGet(self::FORM_PATH);
$this
->assertSession()
->statusCodeEquals(403);
$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.');
$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.');
}
}