LikeEscape.php 525 B

1234567891011121314151617181920212223242526272829
  1. <?php
  2. /**
  3. * @group formatting
  4. */
  5. class Tests_Formatting_LikeEscape extends WP_UnitTestCase {
  6. /**
  7. * @ticket 10041
  8. */
  9. function test_like_escape() {
  10. $inputs = array(
  11. 'howdy%', //Single Percent
  12. 'howdy_', //Single Underscore
  13. 'howdy\\', //Single slash
  14. 'howdy\\howdy%howdy_', //The works
  15. );
  16. $expected = array(
  17. "howdy\\%",
  18. 'howdy\\_',
  19. 'howdy\\\\',
  20. 'howdy\\\\howdy\\%howdy\\_'
  21. );
  22. foreach ($inputs as $key => $input) {
  23. $this->assertEquals($expected[$key], like_escape($input));
  24. }
  25. }
  26. }