EmailValidatorTest.php in Drupal 10
File
core/tests/Drupal/Tests/Component/Utility/EmailValidatorTest.php
View source
<?php
namespace Drupal\Tests\Component\Utility;
use Drupal\Component\Utility\EmailValidator;
use Egulias\EmailValidator\Validation\RFCValidation;
use PHPUnit\Framework\TestCase;
class EmailValidatorTest extends TestCase {
public function testIsValid() {
$validator = new EmailValidator();
$this
->assertTrue($validator
->isValid('example@example.com'));
$this
->assertFalse($validator
->isValid('example@example.com@'));
$this
->assertFalse($validator
->isValid('example@example .com'));
}
public function testIsValidException() {
$validator = new EmailValidator();
$this
->expectException(\BadMethodCallException::class);
$this
->expectExceptionMessage('Calling \\Drupal\\Component\\Utility\\EmailValidator::isValid() with the second argument is not supported. See https://www.drupal.org/node/2997196');
$validator
->isValid('example@example.com', new RFCValidation());
}
}