Skip to content

Commit

Permalink
Test newly created variations are returned by the endpoint
Browse files Browse the repository at this point in the history
  • Loading branch information
oandregal committed Jun 12, 2024
1 parent 10a638a commit a40bb88
Showing 1 changed file with 49 additions and 0 deletions.
49 changes: 49 additions & 0 deletions tests/phpunit/tests/rest-api/rest-global-styles-controller.php
Original file line number Diff line number Diff line change
Expand Up @@ -602,6 +602,55 @@ public function test_update_item_invalid_styles_css() {
$this->assertErrorResponse( 'rest_custom_css_illegal_markup', $response, 400 );
}

/**
* Tests the submission of a custom block style variation that was defined
* within a theme style variation and wouldn't be registered at the time
* of saving via the API.
*
* @covers WP_REST_Global_Styles_Controller_Gutenberg::update_item
* @ticket 61312
*/
public function test_update_item_with_custom_block_style_variations() {
wp_set_current_user( self::$admin_id );
if ( is_multisite() ) {
grant_super_admin( self::$admin_id );
}

$group_variations = array(
'fromThemeStyleVariation' => array(
'color' => array(
'background' => '#ffffff',
'text' => '#000000',
),
),
);

$request = new WP_REST_Request( 'PUT', '/wp/v2/global-styles/' . self::$global_styles_id );
$request->set_body_params(
array(
'styles' => array(
'blocks' => array(
'variations' => array(
'fromThemeStyleVariation' => array(
'blockTypes' => array( 'core/group', 'core/columns' ),
'color' => array(
'background' => '#000000',
'text' => '#ffffff',
),
),
),
'core/group' => array(
'variations' => $group_variations,
),
),
),
)
);
$response = rest_get_server()->dispatch( $request );
$data = $response->get_data();
$this->assertSame( $group_variations, $data['styles']['blocks']['core/group']['variations'] );
}

/**
* @doesNotPerformAssertions
*/
Expand Down

0 comments on commit a40bb88

Please sign in to comment.