shell: Run firejail inside limit.sh, make NO_EXECVE work
[lhc/web/wiklou.git] / tests / phpunit / includes / SanitizerValidateEmailTest.php
index 14d799c..2448513 100644 (file)
@@ -1,62 +1,82 @@
 <?php
 
-class SanitizerValidateEmailTest extends MediaWikiTestCase {
+/**
+ * @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 PHPUnit_Framework_TestCase {
+
+       private function checkEmail( $addr, $expected = true, $msg = '' ) {
+               if ( $msg == '' ) {
+                       $msg = "Testing $addr";
+               }
 
-       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 );
        }
 
-       function testEmailWellKnownUserAtHostDotTldAreValid() {
+       public function testEmailWellKnownUserAtHostDotTldAreValid() {
                $this->valid( 'user@example.com' );
                $this->valid( 'user@example.museum' );
        }
-       function testEmailWithUpperCaseCharactersAreValid() {
+
+       public function testEmailWithUpperCaseCharactersAreValid() {
                $this->valid( 'USER@example.com' );
                $this->valid( 'user@EXAMPLE.COM' );
                $this->valid( 'user@Example.com' );
                $this->valid( 'USER@eXAMPLE.com' );
        }
-       function testEmailWithAPlusInUserName() {
+
+       public function testEmailWithAPlusInUserName() {
                $this->valid( 'user+sub@example.com' );
                $this->valid( 'user+@example.com' );
        }
-       function testEmailDoesNotNeedATopLevelDomain() {
+
+       public function testEmailDoesNotNeedATopLevelDomain() {
                $this->valid( "user@localhost" );
                $this->valid( "FooBar@localdomain" );
                $this->valid( "nobody@mycompany" );
        }
-       function testEmailWithWhiteSpacesBeforeOrAfterAreInvalids() {
+
+       public function testEmailWithWhiteSpacesBeforeOrAfterAreInvalids() {
                $this->invalid( " user@host.com" );
                $this->invalid( "user@host.com " );
                $this->invalid( "\tuser@host.com" );
                $this->invalid( "user@host.com\t" );
        }
-       function testEmailWithWhiteSpacesAreInvalids() {
+
+       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
-       function testEmailWithCommasAreInvalids() {
+
+       /**
+        * T28948 : comma were matched by an incorrect regexp range
+        */
+       public function testEmailWithCommasAreInvalids() {
                $this->invalid( "user,foo@example.org" );
                $this->invalid( "userfoo@ex,ample.org" );
        }
-       function testEmailWithHyphens() {
+
+       public function testEmailWithHyphens() {
                $this->valid( "user-foo@example.org" );
                $this->valid( "userfoo@ex-ample.org" );
        }
-       function testEmailDomainCanNotBeginWithDot() {
+
+       public function testEmailDomainCanNotBeginWithDot() {
                $this->invalid( "user@." );
                $this->invalid( "user@.localdomain" );
                $this->invalid( "user@localdomain." );
@@ -64,16 +84,20 @@ class SanitizerValidateEmailTest extends MediaWikiTestCase {
                $this->valid( ".@localdomain" );
                $this->invalid( ".@a............" );
        }
-       function testEmailWithFunnyCharacters() {
+
+       public function testEmailWithFunnyCharacters() {
                $this->valid( "\$user!ex{this}@123.com" );
        }
-       function testEmailTopLevelDomainCanBeNumerical() {
+
+       public function testEmailTopLevelDomainCanBeNumerical() {
                $this->valid( "user@example.1234" );
        }
-       function testEmailWithoutAtSignIsInvalid() {
+
+       public function testEmailWithoutAtSignIsInvalid() {
                $this->invalid( 'useràexample.com' );
        }
-       function testEmailWithOneCharacterDomainIsValid() {
+
+       public function testEmailWithOneCharacterDomainIsValid() {
                $this->valid( 'user@a' );
        }
 }