Index: tests/phpunit/tests/dependencies/scripts.php
===================================================================
--- tests/phpunit/tests/dependencies/scripts.php	(revision 41829)
+++ tests/phpunit/tests/dependencies/scripts.php	(working copy)
@@ -724,4 +724,360 @@
 
 		$this->assertEquals( $expected, get_echo( 'wp_print_scripts' ) );
 	}
+
+	/**
+	 * 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'] )
+		);
+	}
 }
Index: tests/phpunit/tests/widgets/custom-html-widget.php
===================================================================
--- tests/phpunit/tests/widgets/custom-html-widget.php	(revision 41829)
+++ tests/phpunit/tests/widgets/custom-html-widget.php	(working copy)
@@ -28,18 +28,49 @@
 	protected $widget_text_args;
 
 	/**
-	 * Test constructor.
+	 * Clean up global scope.
 	 *
-	 * @covers WP_Widget_Custom_HTML::__constructor
+	 * @global WP_Scripts $wp_scripts
+	 * @global WP_Styles  $wp_style
 	 */
-	function test_constructor() {
+	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
+	 */
+	function test_construct() {
 		$widget = new WP_Widget_Custom_HTML();
 		$this->assertEquals( 'custom_html', $widget->id_base );
 		$this->assertEquals( 'widget_custom_html', $widget->widget_options['classname'] );
+		$this->assertEquals( 400, $widget->control_options['width'] );
+		$this->assertEquals( 350, $widget->control_options['height'] );
 		$this->assertTrue( $widget->widget_options['customize_selective_refresh'] );
 	}
 
 	/**
+	 * Test enqueue_admin_scripts method.
+	 *
+	 * @covers WP_Widget_Custom_HTML::_register
+	 */
+	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'] );
+	}
+
+	/**
 	 * Test widget method.
 	 *
 	 * @covers WP_Widget_Custom_HTML::widget
@@ -196,4 +227,72 @@
 		}
 		return $caps;
 	}
+
+	/**
+	 * Test enqueue_admin_scripts method. Condition: logged_in, syntax_highlighting is on
+	 *
+	 * @covers WP_Widget_Custom_HTML::enqueue_admin_scripts
+	 */
+	function test_enqueue_admin_scripts_when_logged_in_and_syntax_highlighting_on() {
+		wp_create_user('test', 'test', 'test@test.com');
+		wp_set_current_user(1, 'test');
+		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' ) );
+		$this->assertTrue( wp_script_is( 'code-editor' ) );
+		$this->assertTrue( wp_script_is( 'wp-codemirror' ) );
+		$this->assertTrue( wp_script_is( 'csslint' ) );
+		$this->assertTrue( wp_script_is( 'jshint' ) );
+		$this->assertTrue( wp_script_is( 'htmlhint' ) );
+	}
+
+	/**
+	 * Test enqueue_admin_scripts method. Condition: logged_in, syntax_highlighting is off
+	 *
+	 * @covers WP_Widget_Custom_HTML::enqueue_admin_scripts
+	 */
+	function test_enqueue_admin_scripts_when_logged_in_and_syntax_highlighting_off() {
+		wp_create_user('test', 'test', 'test@test.com');
+		wp_set_current_user(1, 'test');
+		wp_get_current_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' ) );
+		$this->assertTrue( wp_script_is( 'code-editor' ) );
+		$this->assertTrue( wp_script_is( 'wp-codemirror' ) );
+		$this->assertFalse( wp_script_is( 'csslint' ) );
+		$this->assertFalse( wp_script_is( 'jshint' ) );
+		$this->assertFalse( wp_script_is( 'htmlhint' ) );
+	}
+
+	/**
+	 * Test render_control_template_scripts method.
+	 *
+	 * @covers WP_Widget_Custom_HTML::render_control_template_scripts
+	 */
+	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
+	 */
+	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 );
+	}
 }
