<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1//EN"
"http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head><meta http-equiv="content-type" content="text/html; charset=utf-8" />
<title>[41855] trunk/tests/phpunit/tests: Code Editor: Add unit tests for `wp_enqueue_code_editor()` and `WP_Widget_Custom_HTML`.</title>
</head>
<body>

<style type="text/css"><!--
#msg dl.meta { border: 1px #006 solid; background: #369; padding: 6px; color: #fff; }
#msg dl.meta dt { float: left; width: 6em; font-weight: bold; }
#msg dt:after { content:':';}
#msg dl, #msg dt, #msg ul, #msg li, #header, #footer, #logmsg { font-family: verdana,arial,helvetica,sans-serif; font-size: 10pt;  }
#msg dl a { font-weight: bold}
#msg dl a:link    { color:#fc3; }
#msg dl a:active  { color:#ff0; }
#msg dl a:visited { color:#cc6; }
h3 { font-family: verdana,arial,helvetica,sans-serif; font-size: 10pt; font-weight: bold; }
#msg pre { overflow: auto; background: #ffc; border: 1px #fa0 solid; padding: 6px; }
#logmsg { background: #ffc; border: 1px #fa0 solid; padding: 1em 1em 0 1em; }
#logmsg p, #logmsg pre, #logmsg blockquote { margin: 0 0 1em 0; }
#logmsg p, #logmsg li, #logmsg dt, #logmsg dd { line-height: 14pt; }
#logmsg h1, #logmsg h2, #logmsg h3, #logmsg h4, #logmsg h5, #logmsg h6 { margin: .5em 0; }
#logmsg h1:first-child, #logmsg h2:first-child, #logmsg h3:first-child, #logmsg h4:first-child, #logmsg h5:first-child, #logmsg h6:first-child { margin-top: 0; }
#logmsg ul, #logmsg ol { padding: 0; list-style-position: inside; margin: 0 0 0 1em; }
#logmsg ul { text-indent: -1em; padding-left: 1em; }#logmsg ol { text-indent: -1.5em; padding-left: 1.5em; }
#logmsg > ul, #logmsg > ol { margin: 0 0 1em 0; }
#logmsg pre { background: #eee; padding: 1em; }
#logmsg blockquote { border: 1px solid #fa0; border-left-width: 10px; padding: 1em 1em 0 1em; background: white;}
#logmsg dl { margin: 0; }
#logmsg dt { font-weight: bold; }
#logmsg dd { margin: 0; padding: 0 0 0.5em 0; }
#logmsg dd:before { content:'\00bb';}
#logmsg table { border-spacing: 0px; border-collapse: collapse; border-top: 4px solid #fa0; border-bottom: 1px solid #fa0; background: #fff; }
#logmsg table th { text-align: left; font-weight: normal; padding: 0.2em 0.5em; border-top: 1px dotted #fa0; }
#logmsg table td { text-align: right; border-top: 1px dotted #fa0; padding: 0.2em 0.5em; }
#logmsg table thead th { text-align: center; border-bottom: 1px solid #fa0; }
#logmsg table th.Corner { text-align: left; }
#logmsg hr { border: none 0; border-top: 2px dashed #fa0; height: 1px; }
#header, #footer { color: #fff; background: #636; border: 1px #300 solid; padding: 6px; }
#patch { width: 100%; }
#patch h4 {font-family: verdana,arial,helvetica,sans-serif;font-size:10pt;padding:8px;background:#369;color:#fff;margin:0;}
#patch .propset h4, #patch .binary h4 {margin:0;}
#patch pre {padding:0;line-height:1.2em;margin:0;}
#patch .diff {width:100%;background:#eee;padding: 0 0 10px 0;overflow:auto;}
#patch .propset .diff, #patch .binary .diff  {padding:10px 0;}
#patch span {display:block;padding:0 10px;}
#patch .modfile, #patch .addfile, #patch .delfile, #patch .propset, #patch .binary, #patch .copfile {border:1px solid #ccc;margin:10px 0;}
#patch ins {background:#dfd;text-decoration:none;display:block;padding:0 10px;}
#patch del {background:#fdd;text-decoration:none;display:block;padding:0 10px;}
#patch .lines, .info {color:#888;background:#fff;}
--></style>
<div id="msg">
<dl class="meta" style="font-size: 105%">
<dt style="float: left; width: 6em; font-weight: bold">Revision</dt> <dd><a style="font-weight: bold" href="https://core.trac.wordpress.org/changeset/41855">41855</a><script type="application/ld+json">{"@context":"http://schema.org","@type":"EmailMessage","description":"Review this Commit","action":{"@type":"ViewAction","url":"https://core.trac.wordpress.org/changeset/41855","name":"Review Commit"}}</script></dd>
<dt style="float: left; width: 6em; font-weight: bold">Author</dt> <dd>westonruter</dd>
<dt style="float: left; width: 6em; font-weight: bold">Date</dt> <dd>2017-10-13 17:57:38 +0000 (Fri, 13 Oct 2017)</dd>
</dl>

<pre style='padding-left: 1em; margin: 2em 0; border-left: 2px solid #ccc; line-height: 1.25; font-size: 105%; font-family: sans-serif'>Code Editor: Add unit tests for `wp_enqueue_code_editor()` and `WP_Widget_Custom_HTML`.

Props ryotsun.
See <a href="https://core.trac.wordpress.org/ticket/12423">#12423</a>.
Fixes <a href="https://core.trac.wordpress.org/ticket/41871">#41871</a>.</pre>

<h3>Modified Paths</h3>
<ul>
<li><a href="#trunktestsphpunittestsdependenciesscriptsphp">trunk/tests/phpunit/tests/dependencies/scripts.php</a></li>
<li><a href="#trunktestsphpunittestswidgetscustomhtmlwidgetphp">trunk/tests/phpunit/tests/widgets/custom-html-widget.php</a></li>
</ul>

</div>
<div id="patch">
<h3>Diff</h3>
<a id="trunktestsphpunittestsdependenciesscriptsphp"></a>
<div class="modfile"><h4 style="background-color: #eee; color: inherit; margin: 1em 0; padding: 1.3em; font-size: 115%">Modified: trunk/tests/phpunit/tests/dependencies/scripts.php</h4>
<pre class="diff"><span>
<span class="info" style="display: block; padding: 0 10px; color: #888">--- trunk/tests/phpunit/tests/dependencies/scripts.php        2017-10-13 14:39:00 UTC (rev 41854)
+++ trunk/tests/phpunit/tests/dependencies/scripts.php  2017-10-13 17:57:38 UTC (rev 41855)
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -724,4 +724,360 @@
</span><span class="cx" style="display: block; padding: 0 10px"> 
</span><span class="cx" style="display: block; padding: 0 10px">                $this->assertEquals( $expected, get_echo( 'wp_print_scripts' ) );
</span><span class="cx" style="display: block; padding: 0 10px">        }
</span><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+
+       /**
+        * Testing `wp_enqueue_code_editor` with file path.
+        *
+        * @ticket 41871
+        * @covers wp_enqueue_code_editor()
+        */
+       public function test_wp_enqueue_code_editor_when_php_file_will_be_passed() {
+               $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 );
+
+               $this->assertEqualSets( array( 'codemirror', 'csslint', 'jshint', 'htmlhint' ), array_keys( $wp_enqueue_code_editor ) );
+               $this->assertEqualSets(
+                       array(
+                               'autoCloseBrackets',
+                               'autoCloseTags',
+                               'continueComments',
+                               'direction',
+                               'extraKeys',
+                               'indentUnit',
+                               'indentWithTabs',
+                               'inputStyle',
+                               'lineNumbers',
+                               'lineWrapping',
+                               'matchBrackets',
+                               'matchTags',
+                               'mode',
+                               'styleActiveLine',
+                       ),
+                       array_keys( $wp_enqueue_code_editor['codemirror'] )
+               );
+
+               $this->assertEqualSets(
+                       array(
+                               'errors',
+                               'box-model',
+                               'display-property-grouping',
+                               'duplicate-properties',
+                               'known-properties',
+                               'outline-none',
+                       ),
+                       array_keys( $wp_enqueue_code_editor['csslint'] )
+               );
+
+               $this->assertEqualSets(
+                       array(
+                               'boss',
+                               'curly',
+                               'eqeqeq',
+                               'eqnull',
+                               'es3',
+                               'expr',
+                               'immed',
+                               'noarg',
+                               'nonbsp',
+                               'onevar',
+                               'quotmark',
+                               'trailing',
+                               'undef',
+                               'unused',
+                               'browser',
+                               'globals',
+                       ),
+                       array_keys( $wp_enqueue_code_editor['jshint'] )
+               );
+
+               $this->assertEqualSets(
+                       array(
+                               'tagname-lowercase',
+                               'attr-lowercase',
+                               'attr-value-double-quotes',
+                               'doctype-first',
+                               'tag-pair',
+                               'spec-char-escape',
+                               'id-unique',
+                               'src-not-empty',
+                               'attr-no-duplication',
+                               'alt-require',
+                               'space-tab-mixed-disabled',
+                               'attr-unsafe-chars',
+                       ),
+                       array_keys( $wp_enqueue_code_editor['htmlhint'] )
+               );
+       }
+
+       /**
+        * Testing `wp_enqueue_code_editor` with `compact`.
+        *
+        * @ticket 41871
+        * @covers wp_enqueue_code_editor()
+        */
+       public function test_wp_enqueue_code_editor_when_generated_array_by_compact_will_be_passed() {
+               $wp_enqueue_code_editor = wp_enqueue_code_editor( compact( 'file' ) );
+               $this->assertNonEmptyMultidimensionalArray( $wp_enqueue_code_editor );
+
+               $this->assertEqualSets( array( 'codemirror', 'csslint', 'jshint', 'htmlhint' ), array_keys( $wp_enqueue_code_editor ) );
+               $this->assertEqualSets(
+                       array(
+                               'continueComments',
+                               'direction',
+                               'extraKeys',
+                               'indentUnit',
+                               'indentWithTabs',
+                               'inputStyle',
+                               'lineNumbers',
+                               'lineWrapping',
+                               'mode',
+                               'styleActiveLine',
+                       ),
+                       array_keys( $wp_enqueue_code_editor['codemirror'] )
+               );
+
+               $this->assertEqualSets(
+                       array(
+                               'errors',
+                               'box-model',
+                               'display-property-grouping',
+                               'duplicate-properties',
+                               'known-properties',
+                               'outline-none',
+                       ),
+                       array_keys( $wp_enqueue_code_editor['csslint'] )
+               );
+
+               $this->assertEqualSets(
+                       array(
+                               'boss',
+                               'curly',
+                               'eqeqeq',
+                               'eqnull',
+                               'es3',
+                               'expr',
+                               'immed',
+                               'noarg',
+                               'nonbsp',
+                               'onevar',
+                               'quotmark',
+                               'trailing',
+                               'undef',
+                               'unused',
+                               'browser',
+                               'globals',
+                       ),
+                       array_keys( $wp_enqueue_code_editor['jshint'] )
+               );
+
+               $this->assertEqualSets(
+                       array(
+                               'tagname-lowercase',
+                               'attr-lowercase',
+                               'attr-value-double-quotes',
+                               'doctype-first',
+                               'tag-pair',
+                               'spec-char-escape',
+                               'id-unique',
+                               'src-not-empty',
+                               'attr-no-duplication',
+                               'alt-require',
+                               'space-tab-mixed-disabled',
+                               'attr-unsafe-chars',
+                       ),
+                       array_keys( $wp_enqueue_code_editor['htmlhint'] )
+               );
+       }
+
+       /**
+        * Testing `wp_enqueue_code_editor` with `array_merge`.
+        *
+        * @ticket 41871
+        * @covers wp_enqueue_code_editor()
+        */
+       public function test_wp_enqueue_code_editor_when_generated_array_by_array_merge_will_be_passed() {
+               $wp_enqueue_code_editor = wp_enqueue_code_editor(
+                       array_merge(
+                               array(
+                                       'type' => 'text/css',
+                                       'codemirror' => array(
+                                               'indentUnit' => 2,
+                                               'tabSize' => 2,
+                                       ),
+                               ),
+                               array()
+                       )
+               );
+
+               $this->assertNonEmptyMultidimensionalArray( $wp_enqueue_code_editor );
+
+               $this->assertEqualSets( array( 'codemirror', 'csslint', 'jshint', 'htmlhint' ), array_keys( $wp_enqueue_code_editor ) );
+               $this->assertEqualSets(
+                       array(
+                               'autoCloseBrackets',
+                               'continueComments',
+                               'direction',
+                               'extraKeys',
+                               'gutters',
+                               'indentUnit',
+                               'indentWithTabs',
+                               'inputStyle',
+                               'lineNumbers',
+                               'lineWrapping',
+                               'lint',
+                               'matchBrackets',
+                               'mode',
+                               'styleActiveLine',
+                               'tabSize',
+                       ),
+                       array_keys( $wp_enqueue_code_editor['codemirror'] )
+               );
+
+               $this->assertEqualSets(
+                       array(
+                               'errors',
+                               'box-model',
+                               'display-property-grouping',
+                               'duplicate-properties',
+                               'known-properties',
+                               'outline-none',
+                       ),
+                       array_keys( $wp_enqueue_code_editor['csslint'] )
+               );
+
+               $this->assertEqualSets(
+                       array(
+                               'boss',
+                               'curly',
+                               'eqeqeq',
+                               'eqnull',
+                               'es3',
+                               'expr',
+                               'immed',
+                               'noarg',
+                               'nonbsp',
+                               'onevar',
+                               'quotmark',
+                               'trailing',
+                               'undef',
+                               'unused',
+                               'browser',
+                               'globals',
+                       ),
+                       array_keys( $wp_enqueue_code_editor['jshint'] )
+               );
+
+               $this->assertEqualSets(
+                       array(
+                               'tagname-lowercase',
+                               'attr-lowercase',
+                               'attr-value-double-quotes',
+                               'doctype-first',
+                               'tag-pair',
+                               'spec-char-escape',
+                               'id-unique',
+                               'src-not-empty',
+                               'attr-no-duplication',
+                               'alt-require',
+                               'space-tab-mixed-disabled',
+                               'attr-unsafe-chars',
+                       ),
+                       array_keys( $wp_enqueue_code_editor['htmlhint'] )
+               );
+       }
+
+       /**
+        * Testing `wp_enqueue_code_editor` with `array`.
+        *
+        * @ticket 41871
+        * @covers wp_enqueue_code_editor()
+        */
+       public function test_wp_enqueue_code_editor_when_simple_array_will_be_passed() {
+               $wp_enqueue_code_editor = wp_enqueue_code_editor(
+                       array(
+                               'type' => 'text/css',
+                               'codemirror' => array(
+                                       'indentUnit' => 2,
+                                       'tabSize' => 2,
+                               ),
+                       )
+               );
+
+               $this->assertNonEmptyMultidimensionalArray( $wp_enqueue_code_editor );
+
+               $this->assertEqualSets( array( 'codemirror', 'csslint', 'jshint', 'htmlhint' ), array_keys( $wp_enqueue_code_editor ) );
+               $this->assertEqualSets(
+                       array(
+                               'autoCloseBrackets',
+                               'continueComments',
+                               'direction',
+                               'extraKeys',
+                               'gutters',
+                               'indentUnit',
+                               'indentWithTabs',
+                               'inputStyle',
+                               'lineNumbers',
+                               'lineWrapping',
+                               'lint',
+                               'matchBrackets',
+                               'mode',
+                               'styleActiveLine',
+                               'tabSize',
+                       ),
+                       array_keys( $wp_enqueue_code_editor['codemirror'] )
+               );
+
+               $this->assertEqualSets(
+                       array(
+                               'errors',
+                               'box-model',
+                               'display-property-grouping',
+                               'duplicate-properties',
+                               'known-properties',
+                               'outline-none',
+                       ),
+                       array_keys( $wp_enqueue_code_editor['csslint'] )
+               );
+
+               $this->assertEqualSets(
+                       array(
+                               'boss',
+                               'curly',
+                               'eqeqeq',
+                               'eqnull',
+                               'es3',
+                               'expr',
+                               'immed',
+                               'noarg',
+                               'nonbsp',
+                               'onevar',
+                               'quotmark',
+                               'trailing',
+                               'undef',
+                               'unused',
+                               'browser',
+                               'globals',
+                       ),
+                       array_keys( $wp_enqueue_code_editor['jshint'] )
+               );
+
+               $this->assertEqualSets(
+                       array(
+                               'tagname-lowercase',
+                               'attr-lowercase',
+                               'attr-value-double-quotes',
+                               'doctype-first',
+                               'tag-pair',
+                               'spec-char-escape',
+                               'id-unique',
+                               'src-not-empty',
+                               'attr-no-duplication',
+                               'alt-require',
+                               'space-tab-mixed-disabled',
+                               'attr-unsafe-chars',
+                       ),
+                       array_keys( $wp_enqueue_code_editor['htmlhint'] )
+               );
+       }
</ins><span class="cx" style="display: block; padding: 0 10px"> }
</span></span></pre></div>
<a id="trunktestsphpunittestswidgetscustomhtmlwidgetphp"></a>
<div class="modfile"><h4 style="background-color: #eee; color: inherit; margin: 1em 0; padding: 1.3em; font-size: 115%">Modified: trunk/tests/phpunit/tests/widgets/custom-html-widget.php</h4>
<pre class="diff"><span>
<span class="info" style="display: block; padding: 0 10px; color: #888">--- trunk/tests/phpunit/tests/widgets/custom-html-widget.php  2017-10-13 14:39:00 UTC (rev 41854)
+++ trunk/tests/phpunit/tests/widgets/custom-html-widget.php    2017-10-13 17:57:38 UTC (rev 41855)
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -28,23 +28,54 @@
</span><span class="cx" style="display: block; padding: 0 10px">        protected $widget_text_args;
</span><span class="cx" style="display: block; padding: 0 10px"> 
</span><span class="cx" style="display: block; padding: 0 10px">        /**
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">-         * Test constructor.
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+  * Clean up global scope.
</ins><span class="cx" style="display: block; padding: 0 10px">          *
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">-         * @covers WP_Widget_Custom_HTML::__constructor
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+  * @global WP_Scripts $wp_scripts
+        * @global WP_Styles  $wp_style
</ins><span class="cx" style="display: block; padding: 0 10px">          */
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">-        function test_constructor() {
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ public function clean_up_global_scope() {
+               global $wp_scripts, $wp_styles;
+               parent::clean_up_global_scope();
+               $wp_scripts = null;
+               $wp_styles = null;
+       }
+
+       /**
+        * Test construct.
+        *
+        * @covers WP_Widget_Custom_HTML::__construct
+        */
+       public function test_construct() {
</ins><span class="cx" style="display: block; padding: 0 10px">                 $widget = new WP_Widget_Custom_HTML();
</span><span class="cx" style="display: block; padding: 0 10px">                $this->assertEquals( 'custom_html', $widget->id_base );
</span><span class="cx" style="display: block; padding: 0 10px">                $this->assertEquals( 'widget_custom_html', $widget->widget_options['classname'] );
</span><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+                $this->assertEquals( 400, $widget->control_options['width'] );
+               $this->assertEquals( 350, $widget->control_options['height'] );
</ins><span class="cx" style="display: block; padding: 0 10px">                 $this->assertTrue( $widget->widget_options['customize_selective_refresh'] );
</span><span class="cx" style="display: block; padding: 0 10px">        }
</span><span class="cx" style="display: block; padding: 0 10px"> 
</span><span class="cx" style="display: block; padding: 0 10px">        /**
</span><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+         * Test enqueue_admin_scripts method.
+        *
+        * @covers WP_Widget_Custom_HTML::_register
+        */
+       public function test__register() {
+               set_current_screen( 'widgets.php' );
+               $widget = new WP_Widget_Custom_HTML();
+               $widget->_register();
+
+               $this->assertEquals( 10, has_action( 'admin_print_scripts-widgets.php', array( $widget, 'enqueue_admin_scripts' ) ) );
+               $this->assertEquals( 10, has_action( 'admin_footer-widgets.php', array( 'WP_Widget_Custom_HTML', 'render_control_template_scripts' ) ) );
+               $this->assertEquals( 10, has_action( 'admin_head-widgets.php', array( 'WP_Widget_Custom_HTML', 'add_help_text' ) ) );
+               $this->assertContains( 'wp.customHtmlWidgets.idBases.push( "custom_html" );', wp_scripts()->registered['custom-html-widgets']->extra['after'] );
+       }
+
+       /**
</ins><span class="cx" style="display: block; padding: 0 10px">          * Test widget method.
</span><span class="cx" style="display: block; padding: 0 10px">         *
</span><span class="cx" style="display: block; padding: 0 10px">         * @covers WP_Widget_Custom_HTML::widget
</span><span class="cx" style="display: block; padding: 0 10px">         */
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">-        function test_widget() {
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ public function test_widget() {
</ins><span class="cx" style="display: block; padding: 0 10px">                 $widget = new WP_Widget_Custom_HTML();
</span><span class="cx" style="display: block; padding: 0 10px">                $content = "<i>Custom HTML</i>\n\n<b>CODE</b>\nLast line.<u>unclosed";
</span><span class="cx" style="display: block; padding: 0 10px"> 
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -105,7 +136,7 @@
</span><span class="cx" style="display: block; padding: 0 10px">         * @param WP_Widget_Custom_HTML $widget   Current widget instance.
</span><span class="cx" style="display: block; padding: 0 10px">         * @return string Widget content.
</span><span class="cx" style="display: block; padding: 0 10px">         */
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">-        function filter_widget_text( $text, $instance, $widget ) {
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ public function filter_widget_text( $text, $instance, $widget ) {
</ins><span class="cx" style="display: block; padding: 0 10px">                 $this->widget_text_args = array( $text, $instance, $widget );
</span><span class="cx" style="display: block; padding: 0 10px">                $text .= '[filter:widget_text]';
</span><span class="cx" style="display: block; padding: 0 10px">                return $text;
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -119,7 +150,7 @@
</span><span class="cx" style="display: block; padding: 0 10px">         * @param WP_Widget_Custom_HTML $widget         Current Custom HTML widget instance.
</span><span class="cx" style="display: block; padding: 0 10px">         * @return string Widget content.
</span><span class="cx" style="display: block; padding: 0 10px">         */
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">-        function filter_widget_custom_html_content( $widget_content, $instance, $widget ) {
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ public function filter_widget_custom_html_content( $widget_content, $instance, $widget ) {
</ins><span class="cx" style="display: block; padding: 0 10px">                 $this->widget_custom_html_content_args = array( $widget_content, $instance, $widget );
</span><span class="cx" style="display: block; padding: 0 10px">                $widget_content .= '[filter:widget_custom_html_content]';
</span><span class="cx" style="display: block; padding: 0 10px">                return $widget_content;
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -130,7 +161,7 @@
</span><span class="cx" style="display: block; padding: 0 10px">         *
</span><span class="cx" style="display: block; padding: 0 10px">         * @covers WP_Widget_Custom_HTML::update
</span><span class="cx" style="display: block; padding: 0 10px">         */
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">-        function test_update() {
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ public function test_update() {
</ins><span class="cx" style="display: block; padding: 0 10px">                 $widget = new WP_Widget_Custom_HTML();
</span><span class="cx" style="display: block; padding: 0 10px">                $instance = array(
</span><span class="cx" style="display: block; padding: 0 10px">                        'title'   => "The\n<b>Title</b>",
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -174,7 +205,7 @@
</span><span class="cx" style="display: block; padding: 0 10px">         * @param string $cap     Capability name.
</span><span class="cx" style="display: block; padding: 0 10px">         * @return array Caps.
</span><span class="cx" style="display: block; padding: 0 10px">         */
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">-        function grant_unfiltered_html_cap( $caps, $cap ) {
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ public function grant_unfiltered_html_cap( $caps, $cap ) {
</ins><span class="cx" style="display: block; padding: 0 10px">                 if ( 'unfiltered_html' === $cap ) {
</span><span class="cx" style="display: block; padding: 0 10px">                        $caps = array_diff( $caps, array( 'do_not_allow' ) );
</span><span class="cx" style="display: block; padding: 0 10px">                        $caps[] = 'unfiltered_html';
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -189,11 +220,79 @@
</span><span class="cx" style="display: block; padding: 0 10px">         * @param string $cap     Capability name.
</span><span class="cx" style="display: block; padding: 0 10px">         * @return array Caps.
</span><span class="cx" style="display: block; padding: 0 10px">         */
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">-        function revoke_unfiltered_html_cap( $caps, $cap ) {
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ public function revoke_unfiltered_html_cap( $caps, $cap ) {
</ins><span class="cx" style="display: block; padding: 0 10px">                 if ( 'unfiltered_html' === $cap ) {
</span><span class="cx" style="display: block; padding: 0 10px">                        $caps = array_diff( $caps, array( 'unfiltered_html' ) );
</span><span class="cx" style="display: block; padding: 0 10px">                        $caps[] = 'do_not_allow';
</span><span class="cx" style="display: block; padding: 0 10px">                }
</span><span class="cx" style="display: block; padding: 0 10px">                return $caps;
</span><span class="cx" style="display: block; padding: 0 10px">        }
</span><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+
+       /**
+        * Test enqueue_admin_scripts method. Condition: logged_in, syntax_highlighting is on.
+        *
+        * @covers WP_Widget_Custom_HTML::enqueue_admin_scripts
+        */
+       public function test_enqueue_admin_scripts_when_logged_in_and_syntax_highlighting_on() {
+               $user = $this->factory()->user->create();
+               wp_set_current_user( $user );
+               wp_get_current_user()->syntax_highlighting = 'true';
+               set_current_screen( 'widgets.php' );
+               $widget = new WP_Widget_Custom_HTML();
+               $widget->enqueue_admin_scripts();
+
+               $this->assertTrue( wp_script_is( 'custom-html-widgets', 'enqueued' ) );
+               $this->assertTrue( wp_script_is( 'code-editor', 'enqueued' ) );
+               $this->assertTrue( wp_script_is( 'wp-codemirror', 'enqueued' ) );
+               $this->assertTrue( wp_script_is( 'csslint', 'enqueued' ) );
+               $this->assertTrue( wp_script_is( 'jshint', 'enqueued' ) );
+               $this->assertTrue( wp_script_is( 'htmlhint', 'enqueued' ) );
+       }
+
+       /**
+        * Test enqueue_admin_scripts method. Condition: logged_in, syntax_highlighting is off.
+        *
+        * @covers WP_Widget_Custom_HTML::enqueue_admin_scripts
+        */
+       public function test_enqueue_admin_scripts_when_logged_in_and_syntax_highlighting_off() {
+               $user = $this->factory()->user->create();
+               wp_set_current_user( $user );
+               update_user_meta( $user, 'syntax_highlighting', 'false' );
+               set_current_screen( 'widgets.php' );
+               $widget = new WP_Widget_Custom_HTML();
+               $widget->enqueue_admin_scripts();
+
+               $this->assertTrue( wp_script_is( 'custom-html-widgets', 'enqueued' ) );
+               $this->assertTrue( wp_script_is( 'code-editor', 'enqueued' ) );
+               $this->assertTrue( wp_script_is( 'wp-codemirror', 'enqueued' ) );
+               $this->assertFalse( wp_script_is( 'csslint', 'enqueued' ) );
+               $this->assertFalse( wp_script_is( 'jshint', 'enqueued' ) );
+               $this->assertFalse( wp_script_is( 'htmlhint', 'enqueued' ) );
+       }
+
+       /**
+        * Test render_control_template_scripts method.
+        *
+        * @covers WP_Widget_Custom_HTML::render_control_template_scripts
+        */
+       public function test_render_control_template_scripts() {
+               ob_start();
+               WP_Widget_Custom_HTML::render_control_template_scripts();
+               $output = ob_get_clean();
+
+               $this->assertContains( '<script type="text/html" id="tmpl-widget-custom-html-control-fields">', $output );
+       }
+
+       /**
+        * Test add_help_text method.
+        *
+        * @covers WP_Widget_Custom_HTML::add_help_text
+        */
+       public function test_add_help_text() {
+               set_current_screen( 'widgets.php' );
+               WP_Widget_Custom_HTML::add_help_text();
+               $content = get_current_screen()->get_help_tab( 'custom_html_widget' )['content'];
+
+               $this->assertContains( 'Use the Custom HTML widget to add arbitrary HTML code to your widget areas.', $content );
+       }
</ins><span class="cx" style="display: block; padding: 0 10px"> }
</span></span></pre>
</div>
</div>

</body>
</html>