PageRenderTime 84ms CodeModel.GetById 12ms RepoModel.GetById 0ms app.codeStats 0ms

/tests/cases/Utf8StristrTest.php

http://github.com/FSX/php-utf8
PHP | 56 lines | 47 code | 9 blank | 0 comment | 0 complexity | 1750d5750945563b8ec4d09800ee2ee7 MD5 | raw file
Possible License(s): LGPL-2.1
  1. <?php
  2. require_once PHP_UTF8_DIR.'/functions/stristr.php';
  3. class Utf8StristrTest extends PHPUnit_Framework_TestCase
  4. {
  5. public function test_substr()
  6. {
  7. $str = 'ińtërnâtiônŕlizćtiřn';
  8. $search = 'NÂT';
  9. $this->assertEquals('nâtiônŕlizćtiřn', utf8\ifind($str, $search));
  10. }
  11. public function test_substr_no_match()
  12. {
  13. $str = 'ińtërnâtiônŕlizćtiřn';
  14. $search = 'foo';
  15. $this->assertFalse(utf8\ifind($str, $search));
  16. }
  17. public function test_empty_search()
  18. {
  19. $str = 'ińtërnâtiônŕlizćtiřn';
  20. $search = '';
  21. $this->assertEquals('ińtërnâtiônŕlizćtiřn', utf8\ifind($str, $search));
  22. }
  23. public function test_empty_str()
  24. {
  25. $str = '';
  26. $search = 'NÂT';
  27. $this->assertFalse(utf8\ifind($str, $search));
  28. }
  29. public function test_empty_both()
  30. {
  31. $str = '';
  32. $search = '';
  33. $this->assertEmpty(utf8\ifind($str, $search));
  34. }
  35. public function test_linefeed_str()
  36. {
  37. $str = "ińt\nërnâtiônŕlizćtiřn";
  38. $search = 'NÂT';
  39. $this->assertEquals('nâtiônŕlizćtiřn', utf8\ifind($str, $search));
  40. }
  41. public function test_linefeed_both()
  42. {
  43. $str = "ińtërn\nâtiônŕlizćtiřn";
  44. $search = "N\nÂT";
  45. $this->assertEquals("n\nâtiônŕlizćtiřn", utf8\ifind($str, $search));
  46. }
  47. }