Skip to content

Commit 3155a43

Browse files
authored
Add tests for LTR stylesheet handling in wp_register_style() and wp_print_styles().
Implements comprehensive PHPUnit tests for verifying LTR stylesheet support. These tests cover: - Proper registration of LTR data using `wp_style_add_data()`. - Behavior differences between LTR and RTL locales. - Ensuring that LTR variants are correctly printed in HTML output via `wp_print_styles()`. - Verification of stylesheet order to confirm that the LTR stylesheet appears after its main counterpart. Includes handling for the deprecation of `print_emoji_styles` to ensure compatibility with WordPress 6.4+. Props asadister. See [#64193](https://core.trac.wordpress.org/ticket/64193).
1 parent 86bd358 commit 3155a43

File tree

1 file changed

+8
-16
lines changed

1 file changed

+8
-16
lines changed

tests/phpunit/tests/dependencies/stylesLTRSupport.php

Lines changed: 8 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -1,21 +1,13 @@
11
<?php
22
/**
3-
* Tests for LTR stylesheet support in wp_register_style() and wp_print_styles().
4-
*
53
* @group dependencies
64
* @group i18n
7-
*
8-
* @ticket 64193
95
*/
106
class Tests_Dependencies_StylesLtrSupport extends WP_UnitTestCase {
117

128
public function set_up(): void {
139
parent::set_up();
14-
15-
// Switch to an RTL locale to test LTR handling.
16-
switch_to_locale( 'fa_IR' );
17-
18-
// Reset styles registry to ensure a clean environment.
10+
switch_to_locale( 'fa_IR' ); // RTL language.
1911
wp_styles()->registered = array();
2012
}
2113

@@ -55,7 +47,7 @@ public function test_ltr_css_suffix_data_is_set() {
5547
*/
5648
public function test_no_ltr_data_for_ltr_locale() {
5749
restore_previous_locale();
58-
switch_to_locale( 'en_US' ); // LTR language
50+
switch_to_locale( 'en_US' ); // LTR language.
5951

6052
$handle = 'sample-style-ltr';
6153
wp_register_style( $handle, 'https://example.com/style.css' );
@@ -65,15 +57,15 @@ public function test_no_ltr_data_for_ltr_locale() {
6557
$this->assertArrayHasKey( 'ltr', $styles->registered[ $handle ]->extra );
6658
$this->assertSame( 'replace', $styles->registered[ $handle ]->extra['ltr'] );
6759
}
68-
6960
/**
70-
* Verify that an LTR stylesheet is printed after its main stylesheet in the HTML output.
61+
* Verify that an LTR stylesheet actually gets printed in HTML output.
7162
*
7263
* @group output
7364
* @ticket 64193
74-
* @expectedDeprecated print_emoji_styles
7565
*/
7666
public function test_ltr_stylesheet_is_printed_in_output() {
67+
$this->setExpectedDeprecated( 'print_emoji_styles' );
68+
7769
global $wp_styles;
7870

7971
// Reset styles registry to ensure a clean environment.
@@ -99,8 +91,8 @@ public function test_ltr_stylesheet_is_printed_in_output() {
9991
$this->assertStringContainsString( 'ltr.css', $output, 'LTR stylesheet was not printed in output.' );
10092

10193
// Verify correct order (LTR after main style).
102-
$mainPos = strpos( $output, 'style.css' );
103-
$ltrPos = strpos( $output, 'ltr.css' );
104-
$this->assertTrue( $ltrPos > $mainPos, 'LTR stylesheet should appear after the main style.' );
94+
$main_pos = strpos( $output, 'style.css' );
95+
$ltr_pos = strpos( $output, 'ltr.css' );
96+
$this->assertTrue( $ltr_pos > $main_pos, 'LTR stylesheet should appear after the main style.' );
10597
}
10698
}

0 commit comments

Comments
 (0)