jenkins-bot has submitted this change and it was merged. ( 
https://gerrit.wikimedia.org/r/385392 )

Change subject: Add more unit tests.
......................................................................


Add more unit tests.

More unit tests ought to exist for AntiSpoof.

Bug: T174195
Change-Id: If963ce2e74900bddfd9f65af0a35c440c8448f63
---
M tests/phpunit/AntiSpoofTest.php
1 file changed, 30 insertions(+), 2 deletions(-)

Approvals:
  MaxSem: Looks good to me, approved
  jenkins-bot: Verified



diff --git a/tests/phpunit/AntiSpoofTest.php b/tests/phpunit/AntiSpoofTest.php
index d65df3b..7ff0b1b 100644
--- a/tests/phpunit/AntiSpoofTest.php
+++ b/tests/phpunit/AntiSpoofTest.php
@@ -1,4 +1,8 @@
 <?php
+
+/**
+ * @group AntiSpoof
+ */
 class AntiSpoofTest extends MediaWikiTestCase {
 
        public function providePositives() {
@@ -10,14 +14,16 @@
                        [ 'Sabbut', 'ЅаЬЬцт' ],
                        [ 'BetoCG', 'ВетоС6' ],
                        [ 'Wanda', 'vv4ndá' ],
-                       [ 'Mario', 'rnAr10' ]
+                       [ 'Mario', 'rnAr10' ],
+                       [ 'CEASAR', 'ceasar' ],
+                       [ 'ceasar', 'CEASAR' ],
+                       [ 'jimmy wales', 'j1mmy w4l35' ]
                ];
        }
 
        /**
         * Some very basic normalization checks
         *
-        * @covers AntiSpoof::checkUnicodeString
         * @dataProvider providePositives
         */
        public function testCheckUnicodeString( $userName, $spooferName ) {
@@ -29,4 +35,26 @@
 
                $this->assertEquals( $a[1], $b[1] );
        }
+
+       public function provideMixedCharSets() {
+               return [
+                       /** Format: username -> spoofing attempt */
+                       [ 'Recursive O Tester', 'Recursive Θ Tester' ],
+                       [ 'Recursive 0 Tester', 'Recursive Θ Tester' ],
+               ];
+       }
+
+       /**
+        * Test mixed character set strings failure.
+        *
+        * @dataProvider provideMixedCharSets
+        */
+        public function testCheckStringMixedCharSetFailure( $userName, 
$spooferName ) {
+                $a = AntiSpoof::checkUnicodeString( $userName );
+                $b = AntiSpoof::checkUnicodeString( $spooferName );
+
+                $this->assertEquals( 'OK', $a[0] );
+                $this->assertEquals( 'ERROR', $b[0] );
+                $this->assertEquals( 'Contains incompatible mixed scripts', 
$b[1] );
+        }
 }

-- 
To view, visit https://gerrit.wikimedia.org/r/385392
To unsubscribe, visit https://gerrit.wikimedia.org/r/settings

Gerrit-MessageType: merged
Gerrit-Change-Id: If963ce2e74900bddfd9f65af0a35c440c8448f63
Gerrit-PatchSet: 8
Gerrit-Project: mediawiki/extensions/AntiSpoof
Gerrit-Branch: master
Gerrit-Owner: Dbarratt <[email protected]>
Gerrit-Reviewer: Dbarratt <[email protected]>
Gerrit-Reviewer: Dmaza <[email protected]>
Gerrit-Reviewer: Kaldari <[email protected]>
Gerrit-Reviewer: MaxSem <[email protected]>
Gerrit-Reviewer: jenkins-bot <>

_______________________________________________
MediaWiki-commits mailing list
[email protected]
https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits

Reply via email to