Skip to content

chore: Add unit tests for media and settings modules - phase 2#130

Open
sabbir1991 wants to merge 1 commit into
mainfrom
chore/php-unit-testing-phase-2
Open

chore: Add unit tests for media and settings modules - phase 2#130
sabbir1991 wants to merge 1 commit into
mainfrom
chore/php-unit-testing-phase-2

Conversation

@sabbir1991
Copy link
Copy Markdown
Member

@sabbir1991 sabbir1991 commented May 29, 2026

What

Adds PHPUnit unit tests for Phase 2, covering six previously untested classes across the MediaLibrary, MediaSharing, and Settings modules.

Why

Continuing the PHPUnit test coverage initiative started in Phase 1.

Related Issue(s):

  • Part of: #

How

Six new test files added following established Phase 1 patterns (smoke tests for hooks, assertSame for logic methods):

File Class Tests
Unit/Modules/Settings/AdminTest.php Settings\Admin 5
Unit/Modules/MediaSharing/AttachmentTest.php MediaSharing\Attachment 6
Unit/Modules/MediaLibrary/ConsumerAdminTest.php MediaLibrary\ConsumerAdmin 4
Unit/Modules/MediaSharing/UserInterfaceTest.php MediaSharing\UserInterface 4
Unit/Modules/MediaSharing/MediaProtectionTest.php MediaSharing\MediaProtection 4
Unit/Modules/MediaLibrary/AdminTest.php MediaLibrary\Admin 7

No source files were modified.

Testing Instructions

  1. Ensure test wp-env is running: npm run wp-env:test start
  2. Run npm run test:php
  3. All 81 tests should pass

Checklist

  • I have read the Contribution Guidelines.
  • I have read the Development Guidelines.
  • My code is tested to the best of my abilities.
  • My code passes all lints (ESLint etc.).
  • My code has detailed inline documentation.
  • I have updated the project documentation as needed.
  • I have added a changeset for this PR using npm run changeset.
Open WordPress Playground Preview

Copilot AI review requested due to automatic review settings May 29, 2026 05:11
@codecov-commenter
Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 17.97%. Comparing base (69e9219) to head (b6f74f0).

Additional details and impacted files
@@             Coverage Diff              @@
##               main     #130      +/-   ##
============================================
+ Coverage     12.73%   17.97%   +5.24%     
  Complexity      666      666              
============================================
  Files            22       22              
  Lines          2748     2748              
============================================
+ Hits            350      494     +144     
+ Misses         2398     2254     -144     
Flag Coverage Δ
unit 17.97% <ø> (+5.24%) ⬆️

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

☔ View full report in Codecov by Sentry.
📢 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.

Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR adds Phase 2 PHPUnit coverage for previously untested Media Library, Media Sharing, and Settings module classes without modifying production code.

Changes:

  • Adds unit tests for Settings admin rendering/action links/body class handling.
  • Adds Media Sharing tests for attachment metadata helpers, UI action filtering, and edit protection.
  • Adds Media Library admin tests for sync query filtering and consumer-site action restrictions.

Reviewed changes

Copilot reviewed 6 out of 6 changed files in this pull request and generated no comments.

Show a summary per file
File Description
tests/phpunit/Unit/Modules/Settings/AdminTest.php Adds Settings admin unit tests.
tests/phpunit/Unit/Modules/MediaSharing/UserInterfaceTest.php Adds media sync column and row-action tests.
tests/phpunit/Unit/Modules/MediaSharing/MediaProtectionTest.php Adds synced attachment capability protection tests.
tests/phpunit/Unit/Modules/MediaSharing/AttachmentTest.php Adds attachment sync metadata helper tests.
tests/phpunit/Unit/Modules/MediaLibrary/ConsumerAdminTest.php Adds consumer admin hook and action filtering tests.
tests/phpunit/Unit/Modules/MediaLibrary/AdminTest.php Adds media library AJAX sync filter query tests.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

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

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants