You are here

public function EmailValidatorTest::testIsValid in Drupal 9

Same name and namespace in other branches
  1. 8 core/tests/Drupal/Tests/Component/Utility/EmailValidatorTest.php \Drupal\Tests\Component\Utility\EmailValidatorTest::testIsValid()

@covers ::isValid

File

core/tests/Drupal/Tests/Component/Utility/EmailValidatorTest.php, line 20

Class

EmailValidatorTest
Tests the EmailValidator utility class.

Namespace

Drupal\Tests\Component\Utility

Code

public function testIsValid() {

  // Note that \Drupal\Component\Utility\EmailValidator wraps
  // \Egulias\EmailValidator\EmailValidator so we don't do anything more than
  // test that the wrapping works since the dependency has its own test
  // coverage.
  $validator = new EmailValidator();
  $this
    ->assertTrue($validator
    ->isValid('example@example.com'));
  $this
    ->assertFalse($validator
    ->isValid('example@example.com@'));
}