You are here

public function DomainRegistrationTest::testDenyCustomMessage in Restrict Domain Registration 8

Tests custom message on deny.

File

src/Tests/DomainRegistrationTest.php, line 121

Class

DomainRegistrationTest
Test if the Domain Registration module allows and denies specified domains.

Namespace

Drupal\domain_registration\Tests

Code

public function testDenyCustomMessage() {
  \Drupal::configFactory()
    ->getEditable('domain_registration.settings')
    ->set('method', DOMAIN_REGISTRATION_DENY)
    ->save();
  \Drupal::configFactory()
    ->getEditable('domain_registration.settings')
    ->set('message', 'foo bar baz')
    ->save();
  \Drupal::configFactory()
    ->getEditable('domain_registration.settings')
    ->set('pattern', 'example.com')
    ->save();

  // Get the user data for registration.
  $edit = [
    'name' => $this
      ->randomMachineName(),
    'mail' => $this
      ->randomMachineName() . '@example.com',
  ];

  // Attempt to register a user with a blacklist email.
  $this
    ->drupalPostForm('user/register', $edit, t('Create new account'));
  $this
    ->assertText(t('foo bar baz'), t('Custom denial message was shown.'));
}