Skip to content
Closed
Changes from 1 commit
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
Prev Previous commit
Next Next commit
Add a unit test for WP_Customize_Manager::handle_load_themes_request.
  • Loading branch information
anton-vlasenko committed Dec 13, 2021
commit 288a52a886df9785f93965c99794b4edbb8ad5f2
32 changes: 32 additions & 0 deletions tests/phpunit/tests/ajax/CustomizeManager.php
Original file line number Diff line number Diff line change
Expand Up @@ -714,4 +714,36 @@ public function test_handle_dismiss_autosave_or_lock_request() {
$this->assertFalse( $this->_last_response_parsed['success'] );
$this->assertSame( 'no_autosave_revision_to_delete', $this->_last_response_parsed['data'] );
}

/**
* Test request for retrieving installed themes.
*
* @ticket 54549
* @covers WP_Customize_Manager::handle_load_themes_request
*/
public function test_wp_ajax_customize_load_themes_action() {
$arguments = array(
'changeset_uuid' => false,
'settings_previewed' => true,
'branching' => false,
);
new WP_Customize_Manager( $arguments );
wp_set_current_user( self::$admin_user_id );
$nonce = wp_create_nonce( 'switch_themes' );
$_POST['nonce'] = $nonce;
$_GET['nonce'] = $nonce;
$_REQUEST['nonce'] = $nonce;
$_POST['theme_action'] = 'installed';
$this->make_ajax_call( 'customize_load_themes' );
$response = $this->_last_response_parsed;
$this->assertTrue( $response['success'] );
$this->assertIsArray( $response['data']['themes'] );
$this->assertIsArray( $response['data']['themes'] );
foreach ( $response['data']['themes'] as $theme ) {
$this->assertNotEmpty( $theme['id'] );
$this->assertNotEmpty( $theme['name'] );
// It must only return non-block themes
$this->assertNotTrue( $theme['block_based'] );
}
}
}