sebastianbergmann / sebastianbergmann/phpunit

Do not depend on `expects()` for test stub implementation

Open
#6,498 0 comments 0 reactions 1 assignee View on GitHub

@sebastianbergmann is already working on this.

Since Feb 8, 2026.

feature/test-doubles type/refactoring
Dominant language
PHP
Stars
20.1k
Forks
2.2k
Avg merge
7h
Merged PRs (30d)
61

Description

The implementation of the method method() of test test double API currently looks like this:

public function method(Constraint|PropertyHook|string $constraint): InvocationStubber
{
    return $this
        ->__phpunit_getInvocationHandler()
        ->expects(new AnyInvokedCount)
        ->method($constraint);
}

This means that the expects() method is called internally even for a test stub.

This is a remnant from the past when test stubs and mock objects were not as strictly separated as they are today.

We should explore whether we can refactor the runtime internals of the test stub functionality so that it does not require this, in an effort to further separate test stubs from mock objects.

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.

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.