mirror of
https://github.com/gosticks/wordpress-develop.git
synced 2025-10-16 12:05:38 +00:00
Tests: Add a unit test for register_block_style_handle() with an RTL locale.
The test ensures that the function loads RTL stylesheets when a locale with the right-to-left text direction is set. Follow-up to [54330]. Props costdev, thomasplevy, audrasjb, mukesh27. Fixes #56797. git-svn-id: https://develop.svn.wordpress.org/trunk@55486 602fd350-edb4-49c9-b593-d223f7449a82
This commit is contained in:
parent
7945c0ce19
commit
9ec9103669
@ -368,6 +368,58 @@ class Tests_Blocks_Register extends WP_UnitTestCase {
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* Tests that register_block_style_handle() loads RTL stylesheets when an RTL locale is set.
|
||||
*
|
||||
* @ticket 56325
|
||||
* @ticket 56797
|
||||
*
|
||||
* @covers ::register_block_style_handle
|
||||
*/
|
||||
public function test_register_block_style_handle_should_load_rtl_stylesheets_for_rtl_text_direction() {
|
||||
global $wp_locale;
|
||||
|
||||
$metadata = array(
|
||||
'file' => DIR_TESTDATA . '/blocks/notice/block.json',
|
||||
'name' => 'unit-tests/test-block-rtl',
|
||||
'style' => 'file:./block.css',
|
||||
);
|
||||
|
||||
$orig_text_dir = $wp_locale->text_direction;
|
||||
$wp_locale->text_direction = 'rtl';
|
||||
|
||||
$handle = register_block_style_handle( $metadata, 'style' );
|
||||
$extra_rtl = wp_styles()->get_data( 'unit-tests-test-block-rtl-style', 'rtl' );
|
||||
$extra_suffix = wp_styles()->get_data( 'unit-tests-test-block-rtl-style', 'suffix' );
|
||||
$extra_path = wp_normalize_path( wp_styles()->get_data( 'unit-tests-test-block-rtl-style', 'path' ) );
|
||||
|
||||
$wp_locale->text_direction = $orig_text_dir;
|
||||
|
||||
$this->assertSame(
|
||||
'unit-tests-test-block-rtl-style',
|
||||
$handle,
|
||||
'The handle did not match the expected handle.'
|
||||
);
|
||||
|
||||
$this->assertSame(
|
||||
'replace',
|
||||
$extra_rtl,
|
||||
'The extra "rtl" data was not "replace".'
|
||||
);
|
||||
|
||||
$this->assertSame(
|
||||
'',
|
||||
$extra_suffix,
|
||||
'The extra "suffix" data was not an empty string.'
|
||||
);
|
||||
|
||||
$this->assertSame(
|
||||
wp_normalize_path( realpath( DIR_TESTDATA . '/blocks/notice/block-rtl.css' ) ),
|
||||
$extra_path,
|
||||
'The "path" did not match the expected path.'
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* @ticket 56664
|
||||
*/
|
||||
|
||||
Loading…
Reference in New Issue
Block a user