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