# This patch file was generated by NetBeans IDE
# This patch can be applied using context Tools: Apply Diff Patch action on respective folder.
# It uses platform neutral UTF-8 encoding.
# Above lines and this line are ignored by the patching process.
Index: moodle/lib/simpletest/testmoodlelib.php
--- moodle/lib/simpletest/testmoodlelib.php Base (1.28)
+++ moodle/lib/simpletest/testmoodlelib.php Locally Modified (Based On 1.28)
@@ -266,6 +266,7 @@
      * @uses PARAM_LOCALURL
      * @uses PARAM_CLEANHTML
      * @uses PARAM_SEQUENCE
+     * @uses PARAM_USERNAME
      * @param mixed $param the variable we are cleaning
      * @param int $type expected format of param after cleaning.
      * @return mixed
@@ -295,6 +296,30 @@
         $this->assertEqual(clean_param('/just/a/path', PARAM_LOCALURL), '/just/a/path');
         $this->assertEqual(clean_param('funny:thing', PARAM_LOCALURL), '');
         $this->assertEqual(clean_param('course/view.php?id=3', PARAM_LOCALURL), 'course/view.php?id=3');
+
+        // Test success condition, if extendedusernamechars == DISABLE;
+        $this->assertEqual(clean_param('johndoe123', PARAM_USERNAME), 'johndoe123' );
+        $this->assertEqual(clean_param('john.doe', PARAM_USERNAME), 'john.doe');
+        $this->assertEqual(clean_param('john-doe', PARAM_USERNAME), 'john-doe');        
+        $this->assertEqual(clean_param('john- doe', PARAM_USERNAME), 'john-doe');
+
+        // Test success condition, if extendedusernamechars == DISABLE;
+        // BUT
+        // Test FAIL condition, if extendedusernamechars == ENABLE;
+        $this->assertEqual(clean_param('john_doe', PARAM_USERNAME), 'johndoe'); 
+        $this->assertEqual(clean_param('john@doe', PARAM_USERNAME), 'johndoe');
+        $this->assertEqual(clean_param('john~doe', PARAM_USERNAME), 'johndoe');
+        $this->assertEqual(clean_param('john´doe', PARAM_USERNAME), 'johndoe');
+        $this->assertEqual(clean_param('john#$%&() ', PARAM_USERNAME), 'john');
+        $this->assertEqual(clean_param('johndóé ', PARAM_USERNAME), 'johnd');
+        
+        // Test success condition, if extendedusernamechars == ENABLE;
+        $this->assertEqual(clean_param('john_doe', PARAM_USERNAME), 'john_doe');
+        $this->assertEqual(clean_param('john@doe', PARAM_USERNAME), 'john@doe');        
+        $this->assertEqual(clean_param('john# $%&()+_^', PARAM_USERNAME), 'john#$%&()+_^');
+        $this->assertEqual(clean_param('john~doe', PARAM_USERNAME), 'john~doe');        
+        $this->assertEqual(clean_param('john´doe', PARAM_USERNAME), 'john´doe');        
+        $this->assertEqual(clean_param('johndóé ', PARAM_USERNAME), 'johndóé');        
     }
 
     function test_validate_param() {
