99 * @coversDefaultClass WP_Token_map
1010 */
1111class Tests_WpTokenMap extends WP_UnitTestCase {
12+ /**
13+ * Small test array matching names to Emoji.
14+ *
15+ * @var array.
16+ */
17+ const ANIMAL_EMOJI = array (
18+ 'cat ' => '🐈 ' ,
19+ 'dog ' => '🐶 ' ,
20+ 'fish ' => '🐟 ' ,
21+ 'mammoth ' => '🦣 ' ,
22+ 'seal ' => '🦭 ' ,
23+ );
24+
1225 /**
1326 * Returns an associative array whose keys are tokens to replace and
1427 * whose values are the replacement strings for those tokens.
@@ -17,6 +30,11 @@ class Tests_WpTokenMap extends WP_UnitTestCase {
1730 * For example, the HTML5 dataset is very large and best served as a
1831 * separate file.
1932 *
33+ * The HTML5 named character reference list is pulled directly from the
34+ * WHATWG spec and stored in the tests directory so it doesn't need to
35+ * be downloaded on every test run. By specification, it cannot change
36+ * and will not be updated.
37+ *
2038 * @ticket 60698.
2139 *
2240 * @param string $dataset_name Which dataset to return.
@@ -31,7 +49,7 @@ private static function get_test_input_array( $dataset_name ) {
3149
3250 case 'HTML5 ' :
3351 if ( ! isset ( $ html5_character_references ) ) {
34- $ dataset = json_decode ( file_get_contents ( __DIR__ . '/../../data/html5-entities.json ' ) , JSON_OBJECT_AS_ARRAY ); // phpcs:ignore.
52+ $ dataset = wp_json_file_decode ( __DIR__ . '/../../data/html5-entities.json ' , JSON_OBJECT_AS_ARRAY );
3553
3654 $ html5_character_references = array ();
3755 foreach ( $ dataset as $ name => $ value ) {
@@ -48,7 +66,7 @@ private static function get_test_input_array( $dataset_name ) {
4866 *
4967 * @return array[].
5068 */
51- public static function data_input_arrays () {
69+ private static function data_input_arrays () {
5270 $ dataset_names = array (
5371 'ANIMALS ' ,
5472 'HTML5 ' ,
@@ -357,7 +375,7 @@ public static function data_html5_test_dataset() {
357375 *
358376 * @return WP_Token_Map
359377 */
360- public static function get_html5_token_map () {
378+ private static function get_html5_token_map () {
361379 static $ html5_token_map = null ;
362380
363381 if ( ! isset ( $ html5_token_map ) ) {
@@ -366,12 +384,4 @@ public static function get_html5_token_map() {
366384
367385 return $ html5_token_map ;
368386 }
369-
370- const ANIMAL_EMOJI = array (
371- 'cat ' => '🐈 ' ,
372- 'dog ' => '🐶 ' ,
373- 'fish ' => '🐟 ' ,
374- 'mammoth ' => '🦣 ' ,
375- 'seal ' => '🦭 ' ,
376- );
377387}
0 commit comments