[ Index ]

PHP Cross Reference of Phabricator

title

Body

[close]

/src/applications/people/storage/__tests__/ -> PhabricatorUserEmailTestCase.php (source)

   1  <?php
   2  
   3  final class PhabricatorUserEmailTestCase extends PhabricatorTestCase {
   4  
   5    public function testEmailValidation() {
   6      $tests = array(
   7        '[email protected]' => true,
   8        '[email protected]_' => true,
   9        '[email protected]' => true,
  10        '[email protected]' => true,
  11        '[email protected]' => true,
  12        '[email protected]' => true,
  13        '[email protected]' => true,
  14        'user@2001:0db8:85a3:0042:1000:8a2e:0370:7334' => true,
  15        '[email protected]' => true,
  16  
  17        '' => false,
  18        str_repeat('a', 256).'@example.com' => false,
  19        'quack' => false,
  20        '@gmail.com' => false,
  21        'usergmail.com' => false,
  22        '"user" [email protected]' => false,
  23        'a,[email protected]' => false,
  24        'a;[email protected]' => false,
  25        '[email protected];[email protected]' => false,
  26        'x@[email protected]' => false,
  27        '@@' => false,
  28        '@' => false,
  29        'user@' => false,
  30  
  31        "[email protected]\n" => false,
  32        "user@\ndomain.com" => false,
  33        "\[email protected]" => false,
  34        "[email protected]\r" => false,
  35        "user@\rdomain.com" => false,
  36        "\[email protected]" => false,
  37      );
  38  
  39      foreach ($tests as $input => $expect) {
  40        $actual = PhabricatorUserEmail::isValidAddress($input);
  41        $this->assertEqual(
  42          $expect,
  43          $actual,
  44          $input);
  45      }
  46    }
  47  
  48  }


Generated: Sun Nov 30 09:20:46 2014 Cross-referenced by PHPXref 0.7.1