', $control );
+
+ foreach ( $param_overrides as $contained ) {
+ $this->assertStringContainsString( $contained, $control );
+ }
+ }
+
+ /**
+ * @ticket 52399
+ * @see wp_widget_control()
+ */
+ public function test_wp_widget_control_edit_link_is_not_hidden_from_js() {
+ $control = $this->render_search_widget_control();
+
+ $this->assertStringContainsString( 'class="widget-control-edit"', $control, 'The Edit/Add text link should remain visible when JavaScript is available, as a plain-text path to the accessible single-widget edit screen.' );
+ $this->assertStringNotContainsString( 'widget-control-edit hide-if-js', $control );
+ }
+
+ /**
+ * Registers a `search-2` widget in `sidebar-1` and renders its control markup via wp_widget_control().
+ *
+ * @param array $param_overrides Optional. Extra values merged into the sidebar params passed to wp_widget_control().
+ * @return string The rendered control markup.
+ */
+ private function render_search_widget_control( array $param_overrides = array() ) {
global $wp_registered_widgets;
update_option(
@@ -810,11 +861,13 @@ public function test_wp_widget_control() {
wp_widgets_init();
require_once ABSPATH . 'wp-admin/includes/widgets.php';
- $widget_id = 'search-2';
- $widget = $wp_registered_widgets[ $widget_id ];
- $params = array(
- 'widget_id' => $widget['id'],
- 'widget_name' => $widget['name'],
+ $widget = $wp_registered_widgets['search-2'];
+ $params = array_merge(
+ array(
+ 'widget_id' => $widget['id'],
+ 'widget_name' => $widget['name'],
+ ),
+ $param_overrides
);
$control_args = array(
0 => $params,
@@ -824,46 +877,7 @@ public function test_wp_widget_control() {
ob_start();
wp_widget_control( ...$sidebar_args );
- $control = ob_get_clean();
- $this->assertNotEmpty( $control );
-
- $this->assertStringContainsString( '