mirror of
https://github.com/gosticks/wordpress-develop.git
synced 2026-07-01 15:50:09 +00:00
Editor: Fix error handling of converting classic to block menus.
Fixes the error handling for when `WP_Classic_To_Block_Menu_Converter::convert()` returns an instance of `WP_Error`. `WP_Navigation_Fallback::create_classic_menu_fallback()` now checks for `is_wp_error()` and if `true`, returns the error. And the `@return` type is updated to `string|WP_Error`. Also includes a fix in the return type in `WP_Classic_To_Block_Menu_Converter::convert()` to return an empty string instead of an array instead, i.e. when bailing out for no menu items returned by `wp_get_nav_menu_items()`. The return type is clearly documented as a `string`. Follow-up to [56052]. Props dlh, get_dave, antonvlasenko, hellofromTonya. Fixes #58823. git-svn-id: https://develop.svn.wordpress.org/trunk@56422 602fd350-edb4-49c9-b593-d223f7449a82
This commit is contained in:
@@ -205,16 +205,14 @@ class WP_Classic_To_Block_Menu_Converter_Test extends WP_UnitTestCase {
|
||||
* @ticket 58557
|
||||
* @covers WP_Classic_To_Block_Menu_Converter::convert
|
||||
*/
|
||||
public function test_returns_empty_array_for_menus_with_no_items() {
|
||||
public function test_returns_empty_string_for_menus_with_no_items() {
|
||||
$menu_id = wp_create_nav_menu( 'Empty Menu' );
|
||||
|
||||
$classic_nav_menu = wp_get_nav_menu_object( $menu_id );
|
||||
|
||||
$blocks = WP_Classic_To_Block_Menu_Converter::convert( $classic_nav_menu );
|
||||
|
||||
$this->assertEmpty( $blocks, 'Result should be empty.' );
|
||||
|
||||
$this->assertIsArray( $blocks, 'Result should be empty array.' );
|
||||
$this->assertSame( '', $blocks, 'Result should be empty string.' );
|
||||
|
||||
wp_delete_nav_menu( $menu_id );
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user