[wp-trac] [WordPress Trac] #41871: Code Editor: Add unit tests

WordPress Trac noreply at wordpress.org
Tue Oct 10 16:08:04 UTC 2017


#41871: Code Editor: Add unit tests
--------------------------+------------------
 Reporter:  westonruter   |       Owner:
     Type:  defect (bug)  |      Status:  new
 Priority:  high          |   Milestone:  4.9
Component:  General       |     Version:
 Severity:  normal        |  Resolution:
 Keywords:  needs-patch   |     Focuses:
--------------------------+------------------

Comment (by ryotsun):

 Although I would like to work on this ticket, I need your some assistance.
 What does the test expect for?

 For example,
 1. confirm its content by using `assertNonEmptyMultidimensionalArray()`
 1. just compared `json formated string` with the result of
 `wp_json_encode()`.

 {{{#!php
 <?php
         function test_wp_enqueue_code_editor() {
                 $real_file = WP_PLUGIN_DIR . '/hello.php';
                 $wp_enqueue_code_editor = wp_enqueue_code_editor( array(
 'file' => $real_file ) );
                 $this->assertNonEmptyMultidimensionalArray(
 $wp_enqueue_code_editor );

                 $settings = array(
                         'codeEditor' => $wp_enqueue_code_editor,
                 );
                 $expected =
 '{"codeEditor":{"codemirror":{"indentUnit":4,"indentWithTabs":true,"inputStyle":"contenteditable","lineNumbers":true,"lineWrapping":true,"styleActiveLine":true,"continueComments":true,"extraKeys
 ":{"Ctrl-
 Space":"autocomplete","Ctrl-\/":"toggleComment","Cmd-\/":"toggleComment","Alt-F":"findPersistent"},"direction":"ltr","mode":"php","autoCloseBrackets":true,"autoCloseTags":true,"matchBrackets":true,"matchTags":{"bothTags":true}},"csslint":{"errors":true
 ,"box-model":true,"display-property-grouping":true,"duplicate-
 properties":true,"known-properties":true,"outline-
 none":true},"jshint":{"boss":true,"curly":true,"eqeqeq":true,"eqnull":true,"es3":true,"expr":true,"immed":true,"noarg":true,"nonbsp":true,"onevar":true,"quotmark":"single","trailing":true,"undef":true,"unused":true,"browser":true,"globals":{"_":false,"Backbone":false,"jQuery":false,"JSON":false,"wp":false}},"htmlhint
 ":{"tagname-lowercase":true,"attr-lowercase":true,"attr-value-double-
 quotes":true,"doctype-first":false,"tag-pair":true,"spec-char-escape":true
 ,"id-unique":true,"src-not-empty":true,"attr-no-duplication":true,"alt-
 require":true,"space-tab-mixed-disabled":"tab","attr-unsafe-
 chars":true}}}';
                 $this->assertEquals( $expected, wp_json_encode( $settings
 ) );
         }
 }}}

 Are something like these okay for tests?

--
Ticket URL: <https://core.trac.wordpress.org/ticket/41871#comment:2>
WordPress Trac <https://core.trac.wordpress.org/>
WordPress publishing platform


More information about the wp-trac mailing list