Changeset 42613 for trunk/tests/phpunit/tests/widgets/text-widget.php
- Timestamp:
- 01/29/2018 11:55:44 PM (7 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/tests/phpunit/tests/widgets/text-widget.php
r42343 r42613 67 67 $this->assertEquals( 10, has_action( 'admin_footer-widgets.php', array( 'WP_Widget_Text', 'render_control_template_scripts' ) ) ); 68 68 $this->assertContains( 'wp.textWidgets.idBases.push( "text" );', wp_scripts()->registered['text-widgets']->extra['after'] ); 69 $this->assertFalse( has_action( 'wp_enqueue_scripts', array( $widget, 'enqueue_preview_scripts' ) ) ); 70 } 71 72 /** 73 * Test register in customize preview. 74 * 75 * @global WP_Customize_Manager $wp_customize 76 * @covers WP_Widget_Text::__construct() 77 * @covers WP_Widget_Text::_register() 78 */ 79 function test__register_in_customize_preview() { 80 global $wp_customize; 81 wp_set_current_user( 82 $this->factory()->user->create( 83 array( 84 'role' => 'administrator', 85 ) 86 ) 87 ); 88 require_once ABSPATH . WPINC . '/class-wp-customize-manager.php'; 89 $wp_customize = new WP_Customize_Manager( 90 array( 91 'changeset_uuid' => wp_generate_uuid4(), 92 ) 93 ); 94 $wp_customize->start_previewing_theme(); 95 96 $widget = new WP_Widget_Text(); 97 $widget->_register(); 98 $this->assertEquals( 10, has_action( 'wp_enqueue_scripts', array( $widget, 'enqueue_preview_scripts' ) ) ); 99 } 100 101 /** 102 * Test enqueue_preview_scripts method. 103 * 104 * @global WP_Scripts $wp_scripts 105 * @global WP_Styles $wp_styles 106 * @covers WP_Widget_Text::enqueue_preview_scripts 107 */ 108 function test_enqueue_preview_scripts() { 109 global $wp_scripts, $wp_styles; 110 $wp_scripts = null; 111 $wp_styles = null; 112 $widget = new WP_Widget_Text(); 113 114 $this->assertFalse( wp_style_is( 'wp-mediaelement' ) ); 115 $this->assertFalse( wp_script_is( 'wp-playlist' ) ); 116 117 ob_start(); 118 $widget->enqueue_preview_scripts(); 119 ob_end_clean(); 120 121 $this->assertTrue( wp_style_is( 'wp-mediaelement' ) ); 122 $this->assertTrue( wp_script_is( 'wp-playlist' ) ); 69 123 } 70 124
Note: See TracChangeset
for help on using the changeset viewer.