EmailAddressTest.php 971 Bytes
Newer Older
Ketan's avatar
Ketan committed
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34
<?php
/**
 * Integration test for \Magento\Framework\Validator\Factory
 *
 * Copyright © Magento, Inc. All rights reserved.
 * See COPYING.txt for license details.
 */
namespace Magento\Framework\Validator\Test\Unit;

use Magento\Framework\Validator\EmailAddress;

class EmailAddressTest extends \PHPUnit\Framework\TestCase
{
    /**
     * Test that the validator ignores TLD validation by default
     */
    public function testDefaultValidateIgnoresTLD()
    {
        /** @var EmailAddress $emailAddress */
        $emailAddress = new EmailAddress();
        $this->assertTrue($emailAddress->isValid("user@domain.unknown"));
    }

    /**
     * Test that the TLD validation can be enabled
     */
    public function testCanValidateTLD()
    {
        /** @var EmailAddress $emailAddress */
        $emailAddress = new EmailAddress();
        $emailAddress->setValidateTld(true);
        $this->assertFalse($emailAddress->isValid("user@domain.unknown"));
    }
}