[TASK] Additional check for valid domain in validEmail()
[Packages/TYPO3.CMS.git] / typo3 / sysext / core / Tests / Unit / Utility / GeneralUtilityTest.php
index ab9e6cb..5aa0b26 100644 (file)
@@ -928,6 +928,22 @@ class GeneralUtilityTest extends \TYPO3\CMS\Core\Tests\UnitTestCase {
                );
        }
 
+       /**
+        * Data provider for valid validEmail's with DNS Check
+        *
+        * @return array Valid email addresses
+        */
+       public function validEmailValidWithDNSCheckDataProvider() {
+               // please take care when adding more addresses to this
+               // provider! Please not add real addresses to prevent
+               // SPAM bots find this addresses.
+               // this array must contain valid domains for the DNS check
+               return array(
+                       'd3dcljkl38c23dasdas@typo3.org' => array('d3dcljkl38c23dasdas@typo3.org'),
+                       'd3dcljkl38c23dasdas@frank-nägler.de' => array('d3dcljkl38c23dasdas@frank-nägler.de')
+               );
+       }
+
        /**
         * @test
         * @dataProvider validEmailValidDataProvider
@@ -936,6 +952,14 @@ class GeneralUtilityTest extends \TYPO3\CMS\Core\Tests\UnitTestCase {
                $this->assertTrue(Utility\GeneralUtility::validEmail($address));
        }
 
+       /**
+        * @test
+        * @dataProvider validEmailValidWithDNSCheckDataProvider
+        */
+       public function validEmailReturnsTrueForValidMailAddressWithCheckDnsRecordForValidMxEntry($address) {
+               $this->assertTrue(Utility\GeneralUtility::validEmail($address, TRUE));
+       }
+
        /**
         * Data provider for invalid validEmail's
         *
@@ -985,6 +1009,14 @@ class GeneralUtilityTest extends \TYPO3\CMS\Core\Tests\UnitTestCase {
                $this->assertFalse(Utility\GeneralUtility::validEmail($address));
        }
 
+       /**
+        * @test
+        * @dataProvider validEmailInvalidDataProvider
+        */
+       public function validEmailReturnsFalseForInvalidMailAddressWithCheckDnsRecordForValidMxEntry($address) {
+               $this->assertFalse(Utility\GeneralUtility::validEmail($address, TRUE));
+       }
+
        //////////////////////////////////
        // Tests concerning inArray
        //////////////////////////////////