URLifyTest.php 1.4 KB

12345678910111213141516171819202122232425262728293031323334
  1. <?php
  2. class URLifyTest extends PHPUnit_Framework_TestCase {
  3. function test_downcode () {
  4. $this->assertEquals (' J\'etudie le francais ', URLify::downcode (' J\'étudie le français '));
  5. $this->assertEquals ('Lo siento, no hablo espanol.', URLify::downcode ('Lo siento, no hablo español.'));
  6. $this->assertEquals ('F3PWS', URLify::downcode ('ΦΞΠΏΣ'));
  7. }
  8. function test_filter () {
  9. $this->assertEquals ('jetudie-le-francais', URLify::filter (' J\'étudie le français '));
  10. $this->assertEquals ('lo-siento-no-hablo-espanol', URLify::filter ('Lo siento, no hablo español.'));
  11. $this->assertEquals ('f3pws', URLify::filter ('ΦΞΠΏΣ'));
  12. // priorization of language-specific maps
  13. $this->assertEquals ('aouaou', URLify::filter ('ÄÖÜäöü',60,"tr"));
  14. $this->assertEquals ('aeoeueaeoeue', URLify::filter ('ÄÖÜäöü',60,"de"));
  15. }
  16. function test_add_chars () {
  17. $this->assertEquals ('¿ ® ¼ ¼ ¾ ¶', URLify::downcode ('¿ ® ¼ ¼ ¾ ¶'));
  18. URLify::add_chars (array (
  19. '¿' => '?', '®' => '(r)', '¼' => '1/4',
  20. '¼' => '1/2', '¾' => '3/4', '¶' => 'P'
  21. ));
  22. $this->assertEquals ('? (r) 1/2 1/2 3/4 P', URLify::downcode ('¿ ® ¼ ¼ ¾ ¶'));
  23. }
  24. function test_remove_words () {
  25. $this->assertEquals ('foo-bar', URLify::filter ('foo bar'));
  26. URLify::remove_words (array ('foo', 'bar'));
  27. $this->assertEquals ('', URLify::filter ('foo bar'));
  28. }
  29. }
  30. ?>