Skip to content

Dominant Color Images: Clean up redundant metadata generation in tests - #2649

Closed
wprashed wants to merge 2 commits into
WordPress:trunkfrom
wprashed:fix/2524-dominant-color-tests-cleanup
Closed

Dominant Color Images: Clean up redundant metadata generation in tests#2649
wprashed wants to merge 2 commits into
WordPress:trunkfrom
wprashed:fix/2524-dominant-color-tests-cleanup

Conversation

@wprashed

Copy link
Copy Markdown

Description

Fixes #2524.

In Dominant_Color_ImagesTestsTestCase, create_upload_object() automatically invokes wp_generate_attachment_metadata(), which triggers the dominant_color_metadata filter and attaches dominant color data.

Subsequent calls to wp_maybe_generate_attachment_metadata() were redundant because metadata was already populated.

Changes

  • Removed redundant wp_maybe_generate_attachment_metadata() calls in class-testcase.php and test-dominant-color.php.
  • Updated test_get_dominant_color_valid() to assert directly on the generated _wp_attachment_metadata, testing the end-to-end flow from upload to metadata storage.

Testing Instructions

  1. Run composer test:dominant-color-images or run PHPUnit on the dominant color images test suite.
  2. Confirm all test assertions pass without regression.

Removes unnecessary calls to wp_maybe_generate_attachment_metadata() following create_upload_object() and asserts directly against generated attachment metadata in test_get_dominant_color_valid().

Fixes WordPress#2524.
@github-actions

Copy link
Copy Markdown

The following accounts have interacted with this PR and/or linked issues. I will continue to update these lists as activity occurs. You can also manually ask me to refresh this list by adding the props-bot label.

If you're merging code through a pull request on GitHub, copy and paste the following into the bottom of the merge commit message.

Co-authored-by: wprashed <wprashed@git.wordpress.org>
Co-authored-by: nickchomey <nickchomey@git.wordpress.org>

To understand the WordPress project's expectations around crediting contributors, please review the Contributor Attribution page in the Core Handbook.

@github-actions github-actions Bot added the [Plugin] Image Placeholders Issues for the Image Placeholders plugin (formerly Dominant Color Images) label Aug 27, 2026
@codecov

codecov Bot commented Aug 27, 2026

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 70.35%. Comparing base (cedbbac) to head (1448132).

Additional details and impacted files
@@           Coverage Diff           @@
##            trunk    #2649   +/-   ##
=======================================
  Coverage   70.35%   70.35%           
=======================================
  Files          91       91           
  Lines        7867     7867           
=======================================
  Hits         5535     5535           
  Misses       2332     2332           
Flag Coverage Δ
multisite 70.35% <ø> (ø)
single 35.17% <ø> (ø)

Flags with carried forward coverage won't be shown. Click here to find out more.

☔ View full report in Codecov by Harness.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

@nickchomey

Copy link
Copy Markdown
Contributor

I'm curious why this was opened when #2527 already exists to address #2524

@westonruter

Copy link
Copy Markdown
Member

@wprashed Please review #2527 instead of opening your own PR.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

[Plugin] Image Placeholders Issues for the Image Placeholders plugin (formerly Dominant Color Images)

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Bug/improvement: The pattern in the dominant-color-images plugin's test functions doesn't make sense

3 participants