Code Duplication    Length = 20-20 lines in 2 locations

tests/phpunit/tests/functions.php 2 locations

@@ 698-717 (lines=20) @@
695
	/**
696
	 * @ticket 28786
697
	 */
698
	function test_wp_json_encode_non_utf8() {
699
		if ( ! function_exists( 'mb_detect_order' ) ) {
700
			$this->markTestSkipped( 'mbstring extension not available.' );
701
		}
702
703
		$old_charsets = $charsets = mb_detect_order();
704
		if ( ! in_array( 'EUC-JP', $charsets ) ) {
705
			$charsets[] = 'EUC-JP';
706
			mb_detect_order( $charsets );
707
		}
708
709
		$eucjp = mb_convert_encoding( 'aあb', 'EUC-JP', 'UTF-8' );
710
		$utf8 = mb_convert_encoding( $eucjp, 'UTF-8', 'EUC-JP' );
711
712
		$this->assertEquals( 'aあb', $utf8 );
713
714
		$this->assertEquals( '"a\u3042b"', wp_json_encode( $eucjp ) );
715
716
		mb_detect_order( $old_charsets );
717
	}
718
719
	/**
720
	 * @ticket 28786
@@ 722-741 (lines=20) @@
719
	/**
720
	 * @ticket 28786
721
	 */
722
	function test_wp_json_encode_non_utf8_in_array() {
723
		if ( ! function_exists( 'mb_detect_order' ) ) {
724
			$this->markTestSkipped( 'mbstring extension not available.' );
725
		}
726
727
		$old_charsets = $charsets = mb_detect_order();
728
		if ( ! in_array( 'EUC-JP', $charsets ) ) {
729
			$charsets[] = 'EUC-JP';
730
			mb_detect_order( $charsets );
731
		}
732
733
		$eucjp = mb_convert_encoding( 'aあb', 'EUC-JP', 'UTF-8' );
734
		$utf8 = mb_convert_encoding( $eucjp, 'UTF-8', 'EUC-JP' );
735
736
		$this->assertEquals( 'aあb', $utf8 );
737
738
		$this->assertEquals( '["c","a\u3042b"]', wp_json_encode( array( 'c', $eucjp ) ) );
739
740
		mb_detect_order( $old_charsets );
741
	}
742
743
	/**
744
	 * @ticket 28786