UrlEncodedToEntities.php 694 B

123456789101112131415161718192021222324
  1. <?php
  2. /**
  3. * @group formatting
  4. */
  5. class Tests_Formatting_UrlEncodedToEntities extends WP_UnitTestCase {
  6. /**
  7. * @dataProvider data
  8. */
  9. function test_convert_urlencoded_to_entities( $u_urlencoded, $entity ) {
  10. $this->assertEquals( $entity, preg_replace_callback('/\%u([0-9A-F]{4})/', '_convert_urlencoded_to_entities', $u_urlencoded ), $entity );
  11. }
  12. function data() {
  13. $input = file( DIR_TESTDATA . '/formatting/utf-8/u-urlencoded.txt' );
  14. $output = file( DIR_TESTDATA . '/formatting/utf-8/entitized.txt' );
  15. $data_provided = array();
  16. foreach ( $input as $key => $value ) {
  17. $data_provided[] = array( trim( $value ), trim( $output[ $key ] ) );
  18. }
  19. return $data_provided;
  20. }
  21. }