Skip to content

Commit 0c76f08

Browse files
committed
Reuse wp_style_is()
1 parent 0175e0b commit 0c76f08

File tree

1 file changed

+5
-7
lines changed

1 file changed

+5
-7
lines changed

plugins/dominant-color-images/tests/test-dominant-color.php

Lines changed: 5 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -95,6 +95,7 @@ public function test_has_transparency_metadata( string $image_path, array $expec
9595
*/
9696
public function test_dominant_color_has_transparency( string $image_path, array $expected_color, bool $expected_transparency ): void {
9797
$this->skip_if_mime_type_unsupported( $image_path );
98+
9899
// Test when metadata is not an array.
99100
$invalid_meta_attachment = self::factory()->attachment->create(
100101
array(
@@ -439,14 +440,13 @@ public function test_dominant_color_add_inline_style(): void {
439440
dominant_color_add_inline_style();
440441

441442
// Verify the style was registered.
442-
global $wp_styles;
443-
$this->assertTrue( isset( $wp_styles->registered['dominant-color-styles'] ) );
443+
$this->assertTrue( wp_style_is( 'dominant-color-styles', 'registered' ) );
444444

445445
// Verify the style was enqueued.
446446
$this->assertTrue( wp_style_is( 'dominant-color-styles', 'enqueued' ) );
447447

448448
// Verify the inline style was added.
449-
$inline_styles = $wp_styles->get_data( 'dominant-color-styles', 'after' );
449+
$inline_styles = wp_styles()->get_data( 'dominant-color-styles', 'after' );
450450
$this->assertNotEmpty( $inline_styles );
451451
$this->assertStringContainsString(
452452
'img[data-dominant-color]:not(.has-transparency) { background-color: var(--dominant-color); }',
@@ -461,14 +461,13 @@ public function test_dominant_color_admin_inline_style(): void {
461461
dominant_color_admin_inline_style();
462462

463463
// Verify the style was registered.
464-
global $wp_styles;
465-
$this->assertTrue( isset( $wp_styles->registered['dominant-color-admin-styles'] ) );
464+
$this->assertTrue( wp_style_is( 'dominant-color-admin-styles', 'registered' ) );
466465

467466
// Verify the style was enqueued.
468467
$this->assertTrue( wp_style_is( 'dominant-color-admin-styles', 'enqueued' ) );
469468

470469
// Verify the inline style was added.
471-
$inline_styles = $wp_styles->get_data( 'dominant-color-admin-styles', 'after' );
470+
$inline_styles = wp_styles()->get_data( 'dominant-color-admin-styles', 'after' );
472471
$this->assertNotEmpty( $inline_styles );
473472
$this->assertStringContainsString(
474473
'.wp-core-ui .attachment-preview[data-dominant-color]:not(.has-transparency) { background-color: var(--dominant-color); }',
@@ -480,7 +479,6 @@ public function test_dominant_color_admin_inline_style(): void {
480479
* @covers ::dominant_color_admin_script
481480
*/
482481
public function test_dominant_color_admin_script(): void {
483-
484482
$output = get_echo( 'dominant_color_admin_script' );
485483

486484
// Verify if script tag exists.

0 commit comments

Comments
 (0)