dev/mail/15 move santize to function and add unit test
[civicrm-core.git] / tests / phpunit / CRM / Core / OptionGroupTest.php
index 8d5764a83ff80a8cc28593d8a5338a8134e750fd..3aa73301e1b7947bd9de87f7fc69dd9732f56152 100644 (file)
@@ -1,7 +1,7 @@
 <?php
 /*
  +--------------------------------------------------------------------+
- | CiviCRM version 4.7                                                |
+ | CiviCRM version 5                                                  |
  +--------------------------------------------------------------------+
  | Copyright CiviCRM LLC (c) 2004-2018                                |
  +--------------------------------------------------------------------+
@@ -91,4 +91,22 @@ class CRM_Core_OptionGroupTest extends CiviUnitTestCase {
     }
   }
 
+
+  public function emailAddressTests() {
+    $tests[] = array('"Name"<email@example.com>', '"Name" <email@example.com>');
+    $tests[] = array('"Name" <email@example.com>', '"Name" <email@example.com>');
+    $tests[] = array('"Name"  <email@example.com>', '"Name" <email@example.com>');
+    return $tests;
+  }
+
+
+  /**
+   * @dataProvider emailAddressTests
+   */
+  public function testSanitizeFromEmailAddress($dirty, $clean) {
+    $form = new CRM_Admin_Form_Options();
+    $actual = $form->sanitizeFromEmailAddress($dirty);
+    $this->assertEquals($actual, $clean);
+  }
+
 }