1f8369d7dSTobias Sarnowski<?php 2f8369d7dSTobias Sarnowski 3f8369d7dSTobias Sarnowskiclass auth_nameencode_test extends DokuWikiTest { 4f8369d7dSTobias Sarnowski 5*1c33cec3SAndreas Gohr function tearDown() : void { 6f8369d7dSTobias Sarnowski global $cache_authname; 7f8369d7dSTobias Sarnowski $cache_authname = array(); 8f8369d7dSTobias Sarnowski } 9f8369d7dSTobias Sarnowski 10f8369d7dSTobias Sarnowski function test_simple(){ 11f8369d7dSTobias Sarnowski $in = 'hey$you'; 12f8369d7dSTobias Sarnowski $out = 'hey%24you'; 13f8369d7dSTobias Sarnowski $this->assertEquals(auth_nameencode($in),$out); 14f8369d7dSTobias Sarnowski } 15f8369d7dSTobias Sarnowski 16f8369d7dSTobias Sarnowski function test_quote(){ 17f8369d7dSTobias Sarnowski $in = 'hey"you'; 18f8369d7dSTobias Sarnowski $out = 'hey%22you'; 19f8369d7dSTobias Sarnowski $this->assertEquals(auth_nameencode($in),$out); 20f8369d7dSTobias Sarnowski } 21f8369d7dSTobias Sarnowski 22d301130eSChristopher Smith function test_apostrophe(){ 23d301130eSChristopher Smith $in = 'hey\'you'; 24d301130eSChristopher Smith $out = 'hey%27you'; 25d301130eSChristopher Smith $this->assertEquals(auth_nameencode($in),$out); 26d301130eSChristopher Smith } 27d301130eSChristopher Smith 28d301130eSChristopher Smith function test_backslash(){ 29d301130eSChristopher Smith $in = 'hey\\you'; 30d301130eSChristopher Smith $out = 'hey%5cyou'; 31d301130eSChristopher Smith $this->assertEquals(auth_nameencode($in),$out); 32d301130eSChristopher Smith } 33d301130eSChristopher Smith 34f8369d7dSTobias Sarnowski function test_complex(){ 35f8369d7dSTobias Sarnowski $in = 'hey $ you !$%! foo '; 36f8369d7dSTobias Sarnowski $out = 'hey%20%24%20you%20%21%24%25%21%20foo%20'; 37f8369d7dSTobias Sarnowski $this->assertEquals(auth_nameencode($in),$out); 38f8369d7dSTobias Sarnowski } 39f8369d7dSTobias Sarnowski 40f8369d7dSTobias Sarnowski function test_complexutf8(){ 41f8369d7dSTobias Sarnowski $in = 'häü $ yü !$%! foo '; 42f8369d7dSTobias Sarnowski $out = 'häü%20%24%20yü%20%21%24%25%21%20foo%20'; 43f8369d7dSTobias Sarnowski $this->assertEquals(auth_nameencode($in),$out); 44f8369d7dSTobias Sarnowski } 45f8369d7dSTobias Sarnowski 46f8369d7dSTobias Sarnowski function test_groupskipon(){ 47f8369d7dSTobias Sarnowski $in = '@hey$you'; 48f8369d7dSTobias Sarnowski $out = '@hey%24you'; 49f8369d7dSTobias Sarnowski $this->assertEquals(auth_nameencode($in,true),$out); 50f8369d7dSTobias Sarnowski } 51f8369d7dSTobias Sarnowski 52f8369d7dSTobias Sarnowski function test_groupskipoff(){ 53f8369d7dSTobias Sarnowski $in = '@hey$you'; 54f8369d7dSTobias Sarnowski $out = '%40hey%24you'; 55f8369d7dSTobias Sarnowski $this->assertEquals(auth_nameencode($in),$out); 56f8369d7dSTobias Sarnowski } 57698e7df8SChristopher Smith 58698e7df8SChristopher Smith // include a two byte utf8 character which shouldn't be encoded 59698e7df8SChristopher Smith function test_hebrew(){ 60698e7df8SChristopher Smith $in = 'nun-נ8'; 61698e7df8SChristopher Smith $expect = 'nun%2dנ8'; 62698e7df8SChristopher Smith 63698e7df8SChristopher Smith $this->assertEquals($expect, auth_nameencode($in)); 64698e7df8SChristopher Smith } 65698e7df8SChristopher Smith 66698e7df8SChristopher Smith // include a three byte utf8 character which shouldn't be encoded 67698e7df8SChristopher Smith function test_devanagiri(){ 68698e7df8SChristopher Smith $in = 'ut-fठ8'; 69698e7df8SChristopher Smith $expect = 'ut%2dfठ8'; 70698e7df8SChristopher Smith 71698e7df8SChristopher Smith $this->assertEquals($expect, auth_nameencode($in)); 72698e7df8SChristopher Smith } 73f8369d7dSTobias Sarnowski} 74f8369d7dSTobias Sarnowski 75f8369d7dSTobias Sarnowski//Setup VIM: ex: et ts=4 : 76