forked from openemr/openemr
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request openemr#7729 from stephenwaite/iss7477-rel-702
ins subscriber name validation fixes see openemr#7477 (openemr#7478) for rel-702
- Loading branch information
Showing
4 changed files
with
92 additions
and
2 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
60 changes: 60 additions & 0 deletions
60
tests/Tests/Unit/library/SanitizeMultiByteCaseInsensitiveStringEqualsTest.php
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,60 @@ | ||
<?php | ||
|
||
/** | ||
* Test cases for the sanitize.inc.php mb_is_string_equal_ci function | ||
* | ||
* @package OpenEMR | ||
* @link http://www.open-emr.org | ||
* @author Stephen Nielson <[email protected]> | ||
* @copyright Copyright (c) 2024 Discover and Change, Inc. <[email protected]> | ||
* @license https://github.com/openemr/openemr/blob/master/LICENSE GNU General Public License 3 | ||
*/ | ||
|
||
namespace OpenEMR\Tests\Unit\library; | ||
|
||
use PHPUnit\Framework\TestCase; | ||
|
||
class SanitizeMultiByteCaseInsensitiveStringEqualsTest extends TestCase | ||
{ | ||
public function testIdenticalStrings() | ||
{ | ||
$this->assertTrue(mb_is_string_equal_ci('Hello', 'Hello')); | ||
} | ||
|
||
public function testComposedCharacters() | ||
{ | ||
// Composed characters that normalize to the same form under NFKC | ||
$this->assertTrue(mb_is_string_equal_ci('é', 'é')); // e + combining acute accent vs é | ||
$this->assertTrue(mb_is_string_equal_ci('ö', 'ö')); // o + combining diaeresis vs ö | ||
} | ||
public function testDecomposedCharacters() | ||
{ | ||
// Decomposed form of Ä: A + combining diaeresis (U+00C4 -> U+0041 U+0308) | ||
$this->assertTrue(mb_is_string_equal_ci('Ä', 'Ä')); | ||
} | ||
public function testCaseInsensitivity() | ||
{ | ||
// Characters that are different in case but should be equal after case folding | ||
$this->assertTrue(mb_is_string_equal_ci('abc', 'ABC')); | ||
$this->assertTrue(mb_is_string_equal_ci('ß', 'SS')); // German eszett (ß) vs SS | ||
$this->assertTrue(mb_is_string_equal_ci('Ä', 'ä')); | ||
} | ||
|
||
public function testDifferentStrings() | ||
{ | ||
$this->assertFalse(mb_is_string_equal_ci('hello', 'world')); | ||
} | ||
|
||
public function testEmptyStrings() | ||
{ | ||
$this->assertTrue(mb_is_string_equal_ci('', '')); | ||
} | ||
|
||
public function testLargeStrings() | ||
{ | ||
// Generate a large string | ||
$string1 = str_repeat('a', 100000); | ||
$string2 = str_repeat('A', 100000); | ||
$this->assertTrue(mb_is_string_equal_ci($string1, $string2)); | ||
} | ||
} |