NormalizeWhitespace.php 932 B

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152
  1. <?php
  2. /**
  3. * @group formatting
  4. */
  5. class Tests_Formatting_NormalizeWhitespace extends WP_UnitTestCase {
  6. /**
  7. * WhitespaceTest Content DataProvider
  8. *
  9. * array( input_txt, converted_output_txt)
  10. */
  11. public function get_input_output() {
  12. return array(
  13. array(
  14. ' ',
  15. '',
  16. ),
  17. array(
  18. "\rTEST\r",
  19. 'TEST',
  20. ),
  21. array(
  22. "\r\nMY TEST CONTENT\r\n",
  23. 'MY TEST CONTENT',
  24. ),
  25. array(
  26. "MY\r\nTEST\r\nCONTENT ",
  27. "MY\nTEST\nCONTENT",
  28. ),
  29. array(
  30. "\tMY\rTEST\rCONTENT ",
  31. "MY\nTEST\nCONTENT",
  32. ),
  33. array(
  34. "\tMY\t\t\tTEST\r\t\t\rCONTENT ",
  35. "MY TEST\n \nCONTENT",
  36. ),
  37. array(
  38. "\tMY TEST \t\t\t CONTENT ",
  39. 'MY TEST CONTENT',
  40. ),
  41. );
  42. }
  43. /**
  44. * Validate the normalize_whitespace function
  45. *
  46. * @dataProvider get_input_output
  47. */
  48. function test_normalize_whitespace( $in_str, $exp_str ) {
  49. $this->assertSame( $exp_str, normalize_whitespace( $in_str ) );
  50. }
  51. }