10 use MediaWikiCoversValidator;
12 private function checkEmail( $addr, $expected =
true, $msg =
'' ) {
14 $msg =
"Testing $addr";
19 Sanitizer::validateEmail( $addr ),
24 private function valid( $addr, $msg =
'' ) {
28 private function invalid( $addr, $msg =
'' ) {
33 $this->
valid(
'user@example.com' );
34 $this->
valid(
'user@example.museum' );
38 $this->
valid(
'USER@example.com' );
39 $this->
valid(
'user@EXAMPLE.COM' );
40 $this->
valid(
'user@Example.com' );
41 $this->
valid(
'USER@eXAMPLE.com' );
45 $this->
valid(
'user+sub@example.com' );
46 $this->
valid(
'user+@example.com' );
50 $this->
valid(
"user@localhost" );
51 $this->
valid(
"FooBar@localdomain" );
52 $this->
valid(
"nobody@mycompany" );
56 $this->
invalid(
" user@host.com" );
57 $this->
invalid(
"user@host.com " );
58 $this->
invalid(
"\tuser@host.com" );
59 $this->
invalid(
"user@host.com\t" );
63 $this->
invalid(
"User user@host" );
64 $this->
invalid(
"first last@mycompany" );
65 $this->
invalid(
"firstlast@my company" );
72 $this->
invalid(
"user,foo@example.org" );
73 $this->
invalid(
"userfoo@ex,ample.org" );
77 $this->
valid(
"user-foo@example.org" );
78 $this->
valid(
"userfoo@ex-ample.org" );
83 $this->
invalid(
"user@.localdomain" );
84 $this->
invalid(
"user@localdomain." );
85 $this->
valid(
"user.@localdomain" );
86 $this->
valid(
".@localdomain" );
87 $this->
invalid(
".@a............" );
91 $this->
valid(
"\$user!ex{this}@123.com" );
95 $this->
valid(
"user@example.1234" );
99 $this->
invalid(
'userà example.com' );
103 $this->
valid(
'user@a' );
Sanitizer::validateEmail.
testEmailWithFunnyCharacters()
testEmailWithWhiteSpacesBeforeOrAfterAreInvalids()
testEmailWellKnownUserAtHostDotTldAreValid()
testEmailDoesNotNeedATopLevelDomain()
testEmailWithUpperCaseCharactersAreValid()
testEmailTopLevelDomainCanBeNumerical()
testEmailWithCommasAreInvalids()
T28948 : comma were matched by an incorrect regexp range.
testEmailWithOneCharacterDomainIsValid()
testEmailDomainCanNotBeginWithDot()
testEmailWithoutAtSignIsInvalid()
testEmailWithWhiteSpacesAreInvalids()
checkEmail( $addr, $expected=true, $msg='')
testEmailWithAPlusInUserName()