[meta] Deprecate PHPUnit mocks in favour of using Prophecy

Created on 27 April 2020, about 4 years ago
Updated 1 May 2024, about 1 month ago

Problem/Motivation

There are two mocking frameworks used in Drupal core. Both are shipped by PHPUnit. Prophecy is the modern one.

Personally, I prefer mocking with Prophecy. So I would suggest promoting Prophecy and stick with it in Drupal core.

In general:

  • Code writing in Prophecy is elegant than writing in PHPUnit mocks
  • Prophecy has better readability
  • Prophecy is extendable
  • New comers only need to know Prophecy, do not have to know both
  • For those who already get familiar with PHPUnit mocks, it should be easy switching to Prophecy even though it's new to them
  • If one of them is chosen by core, it means no other choice, at some times, no choice is the best choice.

Proposed resolution

  1. Deprecate PHPUnit mocks, and replace existed usages by using Prophecy.
  2. It's hard to have a proper scope, as this is kind of code refactoring. Maybe doing it module by module or component by component is better.

Remaining tasks

Needs discussion:

  1. Is this worthy doing?
  2. If it's worthy, what's the policy/scope for filing child issues?

User interface changes

API changes

Data model changes

Release notes snippet

📌 Task
Status

Active

Version

11.0 🔥

Component
PHPUnit  →

Last updated about 8 hours ago

Created by

🇨🇳China jungle Chongqing, China

Live updates comments and jobs are added and updated live.
Sign in to follow issues

Comments & Activities

Not all content is available!

It's likely this issue predates Contrib.social: some issue and comment data are missing.

  • 🇫🇷France andypost

    Looking back at PHP 8.3 compatibility and facing incompatibilities with PHP 8.4 (initial adoption) I'd better close it as wont fix

    each time prophecy mocks are late for new PHP version compatibility

Production build 0.69.0 2024