Skip to content

Tests: Add unit test coverage for Admin\Deactivation routine - #1022

Merged
dkotter merged 3 commits into
WordPress:developfrom
noruzzamans:add/deactivation-unit-tests
Sep 14, 2026
Merged

dkotter merged 3 commits into
WordPress:developfrom
noruzzamans:add/deactivation-unit-tests

Conversation

@noruzzamans

@noruzzamans noruzzamans commented Sep 11, 2026 •

Copy link
Copy Markdown
Contributor

What?

Closes #1021

Adds unit test coverage for the Admin\Deactivation routine in tests/Integration/Includes/Admin/DeactivationTest.php.

Why?

Currently, the plugin provides integration test coverage for the activation routine in tests/Integration/Includes/Admin/ActivationTest.php, but includes/Admin/Deactivation.php lacked dedicated unit/integration test coverage. Adding this test suite ensures that deactivation logic is verified and protected against regressions (such as properly decrypting and restoring keys when Key Encryption is enabled, and remaining a no-op when disabled).

How?

  • Created tests/Integration/Includes/Admin/DeactivationTest.php with the following test cases:
    1. test_deactivation_callback_with_experiment_disabled_is_noop(): Verifies that deactivation_callback() is a safe no-op when Key Encryption is not effectively enabled.
    2. test_deactivation_callback_restores_plaintext_when_enabled(): Verifies that deactivation_callback() restores plaintext API keys to wp_options and cleans up encrypted secrets when Key Encryption is active.

Use of AI Tools

AI assistance: Yes
Model(s): Gemini 3.8 Flash High
Used for: Identifying missing test coverage for Deactivation.php, structuring the test class, and reviewing against existing test patterns in ActivationTest.php and Key_EncryptionTest.php. Final implementation was reviewed, tested, and verified by me.

Testing Instructions

  1. Run coding standards:
    composer lint
  2. Run static analysis:
    composer phpstan
  3. Run JS/TS checks:
    npm run typecheck && npm run lint:js
  4. Verify that tests/Integration/Includes/Admin/DeactivationTest.php passes cleanly.

Changelog Entry

Developer - Added unit test coverage for Admin\Deactivation routine.

Open WordPress Playground Preview

@noruzzamans
noruzzamans requested a review from a team September 11, 2026 10:22
@github-actions

github-actions Bot commented Sep 11, 2026 •

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: noruzzamans <noruzzaman@git.wordpress.org>
Co-authored-by: dkotter <dkotter@git.wordpress.org>

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

@dkotter dkotter left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

There are some test failures here that need cleaned up before proceeding

@codecov

codecov Bot commented Sep 12, 2026

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 81.67%. Comparing base (f5dd5d8) to head (aa60aa1).

Additional details and impacted files
@@              Coverage Diff              @@
##             develop    #1022      +/-   ##
=============================================
+ Coverage      81.51%   81.67%   +0.16%     
  Complexity      2924     2924              
=============================================
  Files            122      122              
  Lines          11655    11655              
=============================================
+ Hits            9500     9519      +19     
+ Misses          2155     2136      -19     
Flag Coverage Δ
unit 81.67% <ø> (+0.16%) ⬆️

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.

@noruzzamans

Copy link
Copy Markdown
Contributor Author

There are some test failures here that need cleaned up before proceeding

Hi @dkotter,

I've fixed the connector schema issue in DeactivationTest, and all tests are now passing successfully. Ready for your re-review whenever you get a chance! Thanks!

@jeffpaul
jeffpaul requested a review from dkotter September 12, 2026 03:47
@jeffpaul jeffpaul added this to the 1.4.0 milestone Sep 12, 2026
@dkotter
dkotter merged commit 580349c into WordPress:develop Sep 14, 2026
33 checks passed
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.

Add unit test coverage for Admin\Deactivation routine

3 participants