EmailAddressTest.php 971 B

12345678910111213141516171819202122232425262728293031323334
  1. <?php
  2. /**
  3. * Integration test for \Magento\Framework\Validator\Factory
  4. *
  5. * Copyright © Magento, Inc. All rights reserved.
  6. * See COPYING.txt for license details.
  7. */
  8. namespace Magento\Framework\Validator\Test\Unit;
  9. use Magento\Framework\Validator\EmailAddress;
  10. class EmailAddressTest extends \PHPUnit\Framework\TestCase
  11. {
  12. /**
  13. * Test that the validator ignores TLD validation by default
  14. */
  15. public function testDefaultValidateIgnoresTLD()
  16. {
  17. /** @var EmailAddress $emailAddress */
  18. $emailAddress = new EmailAddress();
  19. $this->assertTrue($emailAddress->isValid("user@domain.unknown"));
  20. }
  21. /**
  22. * Test that the TLD validation can be enabled
  23. */
  24. public function testCanValidateTLD()
  25. {
  26. /** @var EmailAddress $emailAddress */
  27. $emailAddress = new EmailAddress();
  28. $emailAddress->setValidateTld(true);
  29. $this->assertFalse($emailAddress->isValid("user@domain.unknown"));
  30. }
  31. }