WordPress / WordPress/Requests

Tests: investigate alternatives for mocking

Open
#814 0 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Type: testing/chores/QA
Dominant language
PHP
Stars
3.6k
Forks
500
Avg merge
2d 21h
Merged PRs (30d)
5

Description

The functionality within PHPUnit itself to mock classes and set expectations on them is being deprecated left right and center, with each upcoming PHPUnit version needing more work-arounds.

While Requests doesn't use mocking much (at all), it is used in a few select places and keeping that working is getting more difficult and will probably become impossible come PHPUnit 11/12.

Typical issues:

  • setMethods() was deprecated in PHPUnit 8.3 and removed in PHPUnit 10.
  • The alternative addMethods() was deprecated in PHPUnit 10.1 and is expected to be removed in PHPUnit 12.
  • The getMockBuilder() method is deprecated and is expected to be removed in PHPUnit 12.

It should be investigated if using Mockery would be an alternative (once it is available with support for PHPUnit 10).

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

No specific files or tests are named. Review the Requests test suite's current PHPUnit mocking usage, check Mockery's PHPUnit 10 support, and determine whether the mocks can be migrated without losing coverage. Done means a decided replacement path compatible with the supported PHPUnit versions.

Written by the indexing model from the issue text.

Assessment

Tech stack
php
Domain
testing
Issue type
Refactor
Difficulty
5/5
Estimated time
Over a week
Activity status
Stale
Clarity
Needs clarification
Newbie friendliness
30/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.