summaryrefslogtreecommitdiff
path: root/tests/phpunit/includes/SanitizerValidateEmailTest.php
diff options
context:
space:
mode:
authorLuke Shumaker <LukeShu@sbcglobal.net>2014-05-05 15:30:48 -0400
committerLuke Shumaker <LukeShu@sbcglobal.net>2014-05-05 15:30:48 -0400
commit3d86add3dfa5e0b3ead9859593d4a52cf7555a34 (patch)
tree453d8bd3fda4dbb3020017ea1a469291da5cdc71 /tests/phpunit/includes/SanitizerValidateEmailTest.php
parent064cec79ca4c8201de0d06bbca6cb7a5345d11be (diff)
parent2e44b49a2db3026050b136de9b00f749dd3ff939 (diff)
Merge branch 'archwiki'
Diffstat (limited to 'tests/phpunit/includes/SanitizerValidateEmailTest.php')
-rw-r--r--tests/phpunit/includes/SanitizerValidateEmailTest.php103
1 files changed, 0 insertions, 103 deletions
diff --git a/tests/phpunit/includes/SanitizerValidateEmailTest.php b/tests/phpunit/includes/SanitizerValidateEmailTest.php
deleted file mode 100644
index f13e8382..00000000
--- a/tests/phpunit/includes/SanitizerValidateEmailTest.php
+++ /dev/null
@@ -1,103 +0,0 @@
-<?php
-
-/**
- * @covers Sanitizer::validateEmail
- * @TODO all test methods in this class should be refactored and...
- * use a single test method and a single data provider...
- */
-class SanitizerValidateEmailTest extends MediaWikiTestCase {
-
- private function checkEmail( $addr, $expected = true, $msg = '' ) {
- if ( $msg == '' ) {
- $msg = "Testing $addr";
- }
-
- $this->assertEquals(
- $expected,
- Sanitizer::validateEmail( $addr ),
- $msg
- );
- }
-
- private function valid( $addr, $msg = '' ) {
- $this->checkEmail( $addr, true, $msg );
- }
-
- private function invalid( $addr, $msg = '' ) {
- $this->checkEmail( $addr, false, $msg );
- }
-
- public function testEmailWellKnownUserAtHostDotTldAreValid() {
- $this->valid( 'user@example.com' );
- $this->valid( 'user@example.museum' );
- }
-
- public function testEmailWithUpperCaseCharactersAreValid() {
- $this->valid( 'USER@example.com' );
- $this->valid( 'user@EXAMPLE.COM' );
- $this->valid( 'user@Example.com' );
- $this->valid( 'USER@eXAMPLE.com' );
- }
-
- public function testEmailWithAPlusInUserName() {
- $this->valid( 'user+sub@example.com' );
- $this->valid( 'user+@example.com' );
- }
-
- public function testEmailDoesNotNeedATopLevelDomain() {
- $this->valid( "user@localhost" );
- $this->valid( "FooBar@localdomain" );
- $this->valid( "nobody@mycompany" );
- }
-
- public function testEmailWithWhiteSpacesBeforeOrAfterAreInvalids() {
- $this->invalid( " user@host.com" );
- $this->invalid( "user@host.com " );
- $this->invalid( "\tuser@host.com" );
- $this->invalid( "user@host.com\t" );
- }
-
- public function testEmailWithWhiteSpacesAreInvalids() {
- $this->invalid( "User user@host" );
- $this->invalid( "first last@mycompany" );
- $this->invalid( "firstlast@my company" );
- }
-
- /**
- * bug 26948 : comma were matched by an incorrect regexp range
- */
- public function testEmailWithCommasAreInvalids() {
- $this->invalid( "user,foo@example.org" );
- $this->invalid( "userfoo@ex,ample.org" );
- }
-
- public function testEmailWithHyphens() {
- $this->valid( "user-foo@example.org" );
- $this->valid( "userfoo@ex-ample.org" );
- }
-
- public function testEmailDomainCanNotBeginWithDot() {
- $this->invalid( "user@." );
- $this->invalid( "user@.localdomain" );
- $this->invalid( "user@localdomain." );
- $this->valid( "user.@localdomain" );
- $this->valid( ".@localdomain" );
- $this->invalid( ".@a............" );
- }
-
- public function testEmailWithFunnyCharacters() {
- $this->valid( "\$user!ex{this}@123.com" );
- }
-
- public function testEmailTopLevelDomainCanBeNumerical() {
- $this->valid( "user@example.1234" );
- }
-
- public function testEmailWithoutAtSignIsInvalid() {
- $this->invalid( 'useràexample.com' );
- }
-
- public function testEmailWithOneCharacterDomainIsValid() {
- $this->valid( 'user@a' );
- }
-}