Source for file utf8_str_ireplace.test.php

Documentation is available at utf8_str_ireplace.test.php

  1. <?php
  2. /**
  3. @version $Id: utf8_str_ireplace.test.php,v 1.1 2007/09/09 20:39:50 pitlinz Exp $
  4. @package utf8
  5. @subpackage Tests
  6. */
  7.  
  8. //--------------------------------------------------------------------
  9. /**
  10. * Includes
  11. @package utf8
  12. @subpackage Tests
  13. */
  14. require_once(dirname(__FILE__).'/../config.php');
  15. require_once UTF8 '/str_ireplace.php';
  16.  
  17. //--------------------------------------------------------------------
  18. /**
  19. @package utf8
  20. @subpackage Tests
  21. */
  22. class test_utf8_str_ireplace extends UnitTestCase {
  23.  
  24.     function test_utf8_str_ireplace({
  25.         $this->UnitTestCase('test_utf8_str_ireplace()');
  26.     }
  27.     
  28.     function testReplace({
  29.         $str 'Iñtërnâtiônàlizætiøn';
  30.         $replaced 'Iñtërnâtiônàlisetiøn';
  31.         $this->assertEqual(utf8_ireplace('lIzÆ','lise',$str),$replaced);
  32.     }
  33.     
  34.     function testReplaceNoMatch({
  35.         $str 'Iñtërnâtiônàlizætiøn';
  36.         $replaced 'Iñtërnâtiônàlizætiøn';
  37.         $this->assertEqual(utf8_ireplace('foo','bar',$str),$replaced);
  38.     }
  39.     
  40.     function testEmptyString({
  41.         $str '';
  42.         $replaced '';
  43.         $this->assertEqual(utf8_ireplace('foo','bar',$str),$replaced);
  44.     }
  45.     
  46.     function testEmptySearch({
  47.         $str 'Iñtërnâtiônàlizætiøn';
  48.         $replaced 'Iñtërnâtiônàlizætiøn';
  49.         $this->assertEqual(utf8_ireplace('','x',$str),$replaced);
  50.     }
  51.     
  52.     function testReplaceCount({
  53.         $str 'Iñtërnâtiônàlizætiøn';
  54.         $replaced 'IñtërXâtiôXàlizætiøn';
  55.         $this->assertEqual(utf8_ireplace('n','X',$str,2),$replaced);
  56.     }
  57.     
  58.         $str 'Iñtërnâtiônàlizætiøn';
  59.         $replaced 'IñtërXXXâtiôXXXàlizætiøXXX';
  60.         $this->assertEqual(utf8_ireplace('n','XXX',$str),$replaced);
  61.     }
  62.     
  63.     function testReplaceArrayAsciiSearch({
  64.         $str 'Iñtërnâtiônàlizætiøn';
  65.         $replaced 'Iñyërxâyiôxàlizæyiøx';
  66.         $this->assertEqual(
  67.             utf8_ireplace(
  68.                 array('n','t'),
  69.                 array('x','y'),
  70.                 $str
  71.                 ),$replaced);
  72.     }
  73.     
  74.     function testReplaceArrayUTF8Search({
  75.         $str 'Iñtërnâtiônàlizætiøn';
  76.         $replaced 'I?tërnâti??nàliz????ti???n';
  77.         $this->assertEqual(
  78.             utf8_ireplace(
  79.                 array('Ñ','ô','ø','Æ'),
  80.                 array('?','??','???','????'),
  81.                 $str
  82.                 ),$replaced);
  83.     }
  84.     
  85.     function testReplaceArrayStringReplace({
  86.         $str 'Iñtërnâtiônàlizætiøn';
  87.         $replaced 'I?tërnâti?nàliz?ti?n';
  88.         $this->assertEqual(
  89.             utf8_ireplace(
  90.                 array('Ñ','ô','ø','Æ'),
  91.                 '?',
  92.                 $str
  93.                 ),$replaced);
  94.     }
  95.     
  96.     function testReplaceArraySingleArrayReplace({
  97.         $str 'Iñtërnâtiônàlizætiøn';
  98.         $replaced 'I?tërnâtinàliztin';
  99.         $this->assertEqual(
  100.             utf8_ireplace(
  101.                 array('Ñ','ô','ø','Æ'),
  102.                 array('?'),
  103.                 $str
  104.                 ),$replaced);
  105.     }
  106.     
  107.     function testReplaceLinefeed({
  108.         $str =      "Iñtërnâti\nônàlizætiøn";
  109.         $replaced "Iñtërnâti\nônàlisetiøn";
  110.         $this->assertEqual(utf8_ireplace('lIzÆ','lise',$str),$replaced);
  111.     }
  112.     
  113.     function testReplaceLinefeedSearch({
  114.         $str =      "Iñtërnâtiônàli\nzætiøn";
  115.         $replaced "Iñtërnâtiônàlisetiøn";
  116.         $this->assertEqual(utf8_ireplace("lI\nzÆ",'lise',$str),$replaced);
  117.     }
  118.     
  119. }
  120.  
  121. //--------------------------------------------------------------------
  122. /**
  123. @package utf8
  124. @subpackage Tests
  125. */
  126. if (!defined('TEST_RUNNING')) {
  127.     define('TEST_RUNNING'true);
  128.     $test new test_utf8_str_ireplace();
  129.     $reporter getTestReporter();
  130.     $test->run($reporter);
  131. }

Documentation generated on Thu, 08 Jan 2009 17:49:19 +0100 by phpDocumentor 1.4.0a2