| | 727 | |
| | 728 | /** |
| | 729 | * Testing `wp_enqueue_code_editor` with file path. |
| | 730 | * @ticket 41871 |
| | 731 | */ |
| | 732 | function test_wp_enqueue_code_editor_when_php_file_will_be_passed() { |
| | 733 | $real_file = WP_PLUGIN_DIR . '/hello.php'; |
| | 734 | $wp_enqueue_code_editor = wp_enqueue_code_editor( array( 'file' => $real_file ) ); |
| | 735 | $this->assertNonEmptyMultidimensionalArray( $wp_enqueue_code_editor ); |
| | 736 | |
| | 737 | $this->assertEqualSets( array( 'codemirror', 'csslint', 'jshint', 'htmlhint' ), array_keys( $wp_enqueue_code_editor ) ); |
| | 738 | $this->assertEqualSets( |
| | 739 | array( |
| | 740 | 'autoCloseBrackets', |
| | 741 | 'autoCloseTags', |
| | 742 | 'continueComments', |
| | 743 | 'direction', |
| | 744 | 'extraKeys', |
| | 745 | 'indentUnit', |
| | 746 | 'indentWithTabs', |
| | 747 | 'inputStyle', |
| | 748 | 'lineNumbers', |
| | 749 | 'lineWrapping', |
| | 750 | 'matchBrackets', |
| | 751 | 'matchTags', |
| | 752 | 'mode', |
| | 753 | 'styleActiveLine', |
| | 754 | ), |
| | 755 | array_keys( $wp_enqueue_code_editor[ 'codemirror' ] ) |
| | 756 | ); |
| | 757 | |
| | 758 | $this->assertEqualSets( |
| | 759 | array( |
| | 760 | 'errors', |
| | 761 | 'box-model', |
| | 762 | 'display-property-grouping', |
| | 763 | 'duplicate-properties', |
| | 764 | 'known-properties', |
| | 765 | 'outline-none', |
| | 766 | ), |
| | 767 | array_keys( $wp_enqueue_code_editor[ 'csslint' ] ) |
| | 768 | ); |
| | 769 | |
| | 770 | $this->assertEqualSets( |
| | 771 | array( |
| | 772 | 'boss', |
| | 773 | 'curly', |
| | 774 | 'eqeqeq', |
| | 775 | 'eqnull', |
| | 776 | 'es3', |
| | 777 | 'expr', |
| | 778 | 'immed', |
| | 779 | 'noarg', |
| | 780 | 'nonbsp', |
| | 781 | 'onevar', |
| | 782 | 'quotmark', |
| | 783 | 'trailing', |
| | 784 | 'undef', |
| | 785 | 'unused', |
| | 786 | 'browser', |
| | 787 | 'globals', |
| | 788 | ), |
| | 789 | array_keys( $wp_enqueue_code_editor[ 'jshint' ] ) |
| | 790 | ); |
| | 791 | |
| | 792 | $this->assertEqualSets( |
| | 793 | array( |
| | 794 | 'tagname-lowercase', |
| | 795 | 'attr-lowercase', |
| | 796 | 'attr-value-double-quotes', |
| | 797 | 'doctype-first', |
| | 798 | 'tag-pair', |
| | 799 | 'spec-char-escape', |
| | 800 | 'id-unique', |
| | 801 | 'src-not-empty', |
| | 802 | 'attr-no-duplication', |
| | 803 | 'alt-require', |
| | 804 | 'space-tab-mixed-disabled', |
| | 805 | 'attr-unsafe-chars', |
| | 806 | ), |
| | 807 | array_keys( $wp_enqueue_code_editor[ 'htmlhint' ] ) |
| | 808 | ); |
| | 809 | } |
| | 810 | |
| | 811 | /** |
| | 812 | * Testing `wp_enqueue_code_editor` with `compact`. |
| | 813 | * @ticket 41871 |
| | 814 | */ |
| | 815 | function test_wp_enqueue_code_editor_when_generated_array_by_compact_will_be_passed() { |
| | 816 | $wp_enqueue_code_editor = wp_enqueue_code_editor( compact('file') ); |
| | 817 | $this->assertNonEmptyMultidimensionalArray( $wp_enqueue_code_editor ); |
| | 818 | |
| | 819 | $this->assertEqualSets( array( 'codemirror', 'csslint', 'jshint', 'htmlhint' ), array_keys( $wp_enqueue_code_editor ) ); |
| | 820 | $this->assertEqualSets( |
| | 821 | array( |
| | 822 | 'continueComments', |
| | 823 | 'direction', |
| | 824 | 'extraKeys', |
| | 825 | 'indentUnit', |
| | 826 | 'indentWithTabs', |
| | 827 | 'inputStyle', |
| | 828 | 'lineNumbers', |
| | 829 | 'lineWrapping', |
| | 830 | 'mode', |
| | 831 | 'styleActiveLine', |
| | 832 | ), |
| | 833 | array_keys( $wp_enqueue_code_editor[ 'codemirror' ] ) |
| | 834 | ); |
| | 835 | |
| | 836 | $this->assertEqualSets( |
| | 837 | array( |
| | 838 | 'errors', |
| | 839 | 'box-model', |
| | 840 | 'display-property-grouping', |
| | 841 | 'duplicate-properties', |
| | 842 | 'known-properties', |
| | 843 | 'outline-none', |
| | 844 | ), |
| | 845 | array_keys( $wp_enqueue_code_editor[ 'csslint' ] ) |
| | 846 | ); |
| | 847 | |
| | 848 | $this->assertEqualSets( |
| | 849 | array( |
| | 850 | 'boss', |
| | 851 | 'curly', |
| | 852 | 'eqeqeq', |
| | 853 | 'eqnull', |
| | 854 | 'es3', |
| | 855 | 'expr', |
| | 856 | 'immed', |
| | 857 | 'noarg', |
| | 858 | 'nonbsp', |
| | 859 | 'onevar', |
| | 860 | 'quotmark', |
| | 861 | 'trailing', |
| | 862 | 'undef', |
| | 863 | 'unused', |
| | 864 | 'browser', |
| | 865 | 'globals', |
| | 866 | ), |
| | 867 | array_keys( $wp_enqueue_code_editor[ 'jshint' ] ) |
| | 868 | ); |
| | 869 | |
| | 870 | $this->assertEqualSets( |
| | 871 | array( |
| | 872 | 'tagname-lowercase', |
| | 873 | 'attr-lowercase', |
| | 874 | 'attr-value-double-quotes', |
| | 875 | 'doctype-first', |
| | 876 | 'tag-pair', |
| | 877 | 'spec-char-escape', |
| | 878 | 'id-unique', |
| | 879 | 'src-not-empty', |
| | 880 | 'attr-no-duplication', |
| | 881 | 'alt-require', |
| | 882 | 'space-tab-mixed-disabled', |
| | 883 | 'attr-unsafe-chars', |
| | 884 | ), |
| | 885 | array_keys( $wp_enqueue_code_editor[ 'htmlhint' ] ) |
| | 886 | ); |
| | 887 | } |
| | 888 | |
| | 889 | /** |
| | 890 | * Testing `wp_enqueue_code_editor` with `array_merge`. |
| | 891 | * @ticket 41871 |
| | 892 | */ |
| | 893 | function test_wp_enqueue_code_editor_when_generated_array_by_array_merge_will_be_passed() { |
| | 894 | $wp_enqueue_code_editor = wp_enqueue_code_editor( |
| | 895 | array_merge( |
| | 896 | array( |
| | 897 | 'type' => "text/css", |
| | 898 | 'codemirror' => array( |
| | 899 | 'indentUnit' => 2, |
| | 900 | 'tabSize' => 2, |
| | 901 | ), |
| | 902 | ), |
| | 903 | array() |
| | 904 | ) |
| | 905 | ); |
| | 906 | |
| | 907 | $this->assertNonEmptyMultidimensionalArray( $wp_enqueue_code_editor ); |
| | 908 | |
| | 909 | $this->assertEqualSets( array( 'codemirror', 'csslint', 'jshint', 'htmlhint' ), array_keys( $wp_enqueue_code_editor ) ); |
| | 910 | $this->assertEqualSets( |
| | 911 | array( |
| | 912 | 'autoCloseBrackets', |
| | 913 | 'continueComments', |
| | 914 | 'direction', |
| | 915 | 'extraKeys', |
| | 916 | 'gutters', |
| | 917 | 'indentUnit', |
| | 918 | 'indentWithTabs', |
| | 919 | 'inputStyle', |
| | 920 | 'lineNumbers', |
| | 921 | 'lineWrapping', |
| | 922 | 'lint', |
| | 923 | 'matchBrackets', |
| | 924 | 'mode', |
| | 925 | 'styleActiveLine', |
| | 926 | 'tabSize', |
| | 927 | ), |
| | 928 | array_keys( $wp_enqueue_code_editor[ 'codemirror' ] ) |
| | 929 | ); |
| | 930 | |
| | 931 | $this->assertEqualSets( |
| | 932 | array( |
| | 933 | 'errors', |
| | 934 | 'box-model', |
| | 935 | 'display-property-grouping', |
| | 936 | 'duplicate-properties', |
| | 937 | 'known-properties', |
| | 938 | 'outline-none', |
| | 939 | ), |
| | 940 | array_keys( $wp_enqueue_code_editor[ 'csslint' ] ) |
| | 941 | ); |
| | 942 | |
| | 943 | $this->assertEqualSets( |
| | 944 | array( |
| | 945 | 'boss', |
| | 946 | 'curly', |
| | 947 | 'eqeqeq', |
| | 948 | 'eqnull', |
| | 949 | 'es3', |
| | 950 | 'expr', |
| | 951 | 'immed', |
| | 952 | 'noarg', |
| | 953 | 'nonbsp', |
| | 954 | 'onevar', |
| | 955 | 'quotmark', |
| | 956 | 'trailing', |
| | 957 | 'undef', |
| | 958 | 'unused', |
| | 959 | 'browser', |
| | 960 | 'globals', |
| | 961 | ), |
| | 962 | array_keys( $wp_enqueue_code_editor[ 'jshint' ] ) |
| | 963 | ); |
| | 964 | |
| | 965 | $this->assertEqualSets( |
| | 966 | array( |
| | 967 | 'tagname-lowercase', |
| | 968 | 'attr-lowercase', |
| | 969 | 'attr-value-double-quotes', |
| | 970 | 'doctype-first', |
| | 971 | 'tag-pair', |
| | 972 | 'spec-char-escape', |
| | 973 | 'id-unique', |
| | 974 | 'src-not-empty', |
| | 975 | 'attr-no-duplication', |
| | 976 | 'alt-require', |
| | 977 | 'space-tab-mixed-disabled', |
| | 978 | 'attr-unsafe-chars', |
| | 979 | ), |
| | 980 | array_keys( $wp_enqueue_code_editor[ 'htmlhint' ] ) |
| | 981 | ); |
| | 982 | } |
| | 983 | |
| | 984 | /** |
| | 985 | * Testing `wp_enqueue_code_editor` with `array`. |
| | 986 | * @ticket 41871 |
| | 987 | */ |
| | 988 | function test_wp_enqueue_code_editor_when_simple_array_will_be_passed() { |
| | 989 | $wp_enqueue_code_editor = wp_enqueue_code_editor( |
| | 990 | array( |
| | 991 | 'type' => "text/css", |
| | 992 | 'codemirror' => array( |
| | 993 | 'indentUnit' => 2, |
| | 994 | 'tabSize' => 2, |
| | 995 | ), |
| | 996 | ) |
| | 997 | ); |
| | 998 | |
| | 999 | $this->assertNonEmptyMultidimensionalArray( $wp_enqueue_code_editor ); |
| | 1000 | |
| | 1001 | $this->assertEqualSets( array( 'codemirror', 'csslint', 'jshint', 'htmlhint' ), array_keys( $wp_enqueue_code_editor ) ); |
| | 1002 | $this->assertEqualSets( |
| | 1003 | array( |
| | 1004 | 'autoCloseBrackets', |
| | 1005 | 'continueComments', |
| | 1006 | 'direction', |
| | 1007 | 'extraKeys', |
| | 1008 | 'gutters', |
| | 1009 | 'indentUnit', |
| | 1010 | 'indentWithTabs', |
| | 1011 | 'inputStyle', |
| | 1012 | 'lineNumbers', |
| | 1013 | 'lineWrapping', |
| | 1014 | 'lint', |
| | 1015 | 'matchBrackets', |
| | 1016 | 'mode', |
| | 1017 | 'styleActiveLine', |
| | 1018 | 'tabSize', |
| | 1019 | ), |
| | 1020 | array_keys( $wp_enqueue_code_editor[ 'codemirror' ] ) |
| | 1021 | ); |
| | 1022 | |
| | 1023 | $this->assertEqualSets( |
| | 1024 | array( |
| | 1025 | 'errors', |
| | 1026 | 'box-model', |
| | 1027 | 'display-property-grouping', |
| | 1028 | 'duplicate-properties', |
| | 1029 | 'known-properties', |
| | 1030 | 'outline-none', |
| | 1031 | ), |
| | 1032 | array_keys( $wp_enqueue_code_editor[ 'csslint' ] ) |
| | 1033 | ); |
| | 1034 | |
| | 1035 | $this->assertEqualSets( |
| | 1036 | array( |
| | 1037 | 'boss', |
| | 1038 | 'curly', |
| | 1039 | 'eqeqeq', |
| | 1040 | 'eqnull', |
| | 1041 | 'es3', |
| | 1042 | 'expr', |
| | 1043 | 'immed', |
| | 1044 | 'noarg', |
| | 1045 | 'nonbsp', |
| | 1046 | 'onevar', |
| | 1047 | 'quotmark', |
| | 1048 | 'trailing', |
| | 1049 | 'undef', |
| | 1050 | 'unused', |
| | 1051 | 'browser', |
| | 1052 | 'globals', |
| | 1053 | ), |
| | 1054 | array_keys( $wp_enqueue_code_editor[ 'jshint' ] ) |
| | 1055 | ); |
| | 1056 | |
| | 1057 | $this->assertEqualSets( |
| | 1058 | array( |
| | 1059 | 'tagname-lowercase', |
| | 1060 | 'attr-lowercase', |
| | 1061 | 'attr-value-double-quotes', |
| | 1062 | 'doctype-first', |
| | 1063 | 'tag-pair', |
| | 1064 | 'spec-char-escape', |
| | 1065 | 'id-unique', |
| | 1066 | 'src-not-empty', |
| | 1067 | 'attr-no-duplication', |
| | 1068 | 'alt-require', |
| | 1069 | 'space-tab-mixed-disabled', |
| | 1070 | 'attr-unsafe-chars', |
| | 1071 | ), |
| | 1072 | array_keys( $wp_enqueue_code_editor[ 'htmlhint' ] ) |
| | 1073 | ); |
| | 1074 | } |