| 965 | * Tests for orphaned widgets being moved into inactive widgets. |
| 966 | * |
| 967 | * @covers retrieve_widgets() |
| 968 | */ |
| 969 | function test_retrieve_widgets_move_orphaned_widgets_to_inactive() { |
| 970 | global $sidebars_widgets; |
| 971 | |
| 972 | wp_widgets_init(); |
| 973 | $this->register_sidebars( array( 'sidebar-1', 'sidebar-2', 'sidebar-3', 'wp_inactive_widgets' ) ); |
| 974 | |
| 975 | $sidebars_widgets = array( |
| 976 | 'sidebar-1' => array( 'tag_cloud-1' ), |
| 977 | 'sidebar-2' => array( 'text-1' ), |
| 978 | 'wp_inactive_widgets' => array( 'search-2', 'archives-2' ), |
| 979 | 'orphaned_widgets_1' => array( 'calendar-1' ), |
| 980 | ); |
| 981 | |
| 982 | retrieve_widgets(); |
| 983 | |
| 984 | $this->assertInternalType( 'array', $sidebars_widgets ); |
| 985 | |
| 986 | foreach ( $sidebars_widgets as $widgets ) { |
| 987 | $this->assertInternalType( 'array', $widgets ); |
| 988 | } |
| 989 | |
| 990 | // 6 default widgets + 1 orphaned calendar widget = 7. |
| 991 | $this->assertCount( 7, $sidebars_widgets['wp_inactive_widgets'] ); |
| 992 | $this->assertContains( 'calendar-1', $sidebars_widgets['wp_inactive_widgets'] ); |
| 993 | $this->assertArrayNotHasKey( 'orphaned_widgets_1', $sidebars_widgets ); |
| 994 | |
| 995 | // Sidebar_widgets option was updated. |
| 996 | $this->assertEquals( $sidebars_widgets, wp_get_sidebars_widgets() ); |
| 997 | } |
| 998 | |
| 999 | /** |