Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add PHPUnit tests for wp_maybe_load_widgets function #5831

Open
wants to merge 3 commits into
base: trunk
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
47 changes: 47 additions & 0 deletions tests/phpunit/tests/functions/wpMaybeLoadWidgets.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
<?php

/**
* Tests for the wp_maybe_load_widgets function.
*
* @group Functions
*
* @covers ::wp_maybe_load_widgets
*/
class Tests_Functions_wpMaybeLoadWidgets extends WP_UnitTestCase {

public $submenu;

public function set_up() {
global $submenu;
$this->submenu = $submenu;
$submenu = null;
}

public function tear_down() {
global $submenu;
$submenu = $this->submenu;
}

/**
* @ticket 60180
*/
public function test_wp_maybe_load_widgets() {

wp_maybe_load_widgets();

$this->assertSame( 10, has_action( '_admin_menu', 'wp_widgets_add_menu' ) );
}

public function test_wp_maybe_load_widgets_no_default_widgets() {
global $submenu;

add_filter( 'load_default_widgets', '__return_false' );

wp_maybe_load_widgets();

remove_filter( 'load_default_widgets', '__return_false' );

$this->assertSame( 10, has_action( '_admin_menu', 'wp_widgets_add_menu' ) );
}

}

Check failure on line 47 in tests/phpunit/tests/functions/wpMaybeLoadWidgets.php

View workflow job for this annotation

GitHub Actions / PHP coding standards

The closing brace for the class must go on the next line after the body
Loading