Report undefined methods in mock ->method('...')

Aperta
#184 0 commenti 0 reazioni 0 assegnatari Vedi su GitHub

I maintainer di solito rispondono entro 1 giorno

@alies-dev ci sta già lavorando.

Dal 9/11/2026.

  • #212 di @alies-dev — aperta

Valutazione

Difficoltà
4/5
Tempo stimato
3-5 giorni
Idoneità per principianti
25/100
Tipo di issue
Funzionalità
Chiarezza
Specificata chiaramente
Stato di attività
Ferma
Stack tecnologico
php
Ambito
testing

Direzione di ricerca

Read the linked MockMethodCallRule in phpstan-phpunit and trace how afterMethodCallAnalysis handles method() calls on InvocationMocker, MockObject, and Stub. Check the receiver type and string literal argument cases, including @method pseudo methods. The issue estimates roughly 100 lines with tests; done means these calls are checked and the tests cover the described cases.

Scritto dal modello di indicizzazione a partire dal testo della issue.

Descrizione

enhancement

A typo or a renamed method in a mock expectation is not reported:

$mailer = $this->createMock(Mailer::class);
$mailer->expects($this->once())->method('sendInvoce'); // Mailer::sendInvoce() doesn't exist

PHPUnit only fails at runtime, and only if that test actually runs. phpstan-phpunit reports it (MockMethodCallRule). A probe showed that ->method('x') after createMock(), after expects() and on createStub() is never checked today.

Idea: in afterMethodCallAnalysis, for method() calls on InvocationMocker/MockObject/Stub, take the mocked class from the receiver type (Foo&MockObject) and check $codebase->methodExists() for a string literal argument (so @method pseudo methods are respected). Roughly 100 lines with tests.

Idea borrowed from phpstan/phpstan-phpunit.

Lingua principale
Gherkin
Stelle
79
Fork
38
Merge medio
6h 52m
PR unite (30g)
28

Preparare l'ambiente

Questo progetto non fornisce container di sviluppo, Dockerfile né guida per i contributori, quindi l'ambiente è a tuo carico: parti dal suo README e consulta la nostra guida al primo contributo per i passaggi generali.

Come iniziare

  1. Leggi tutta la issue e poi la guida ai contributi del progetto.
  2. Commenta sulla issue per dire che te ne occupi tu — evita che due persone facciano lo stesso lavoro.
  3. Fai un fork del repository e lavora su un branch.
  4. Apri una pull request che faccia riferimento al numero della issue.

Altre issue di psalm/psalm-plugin-phpunit

Tutte le issue di psalm/psalm-plugin-phpunit

Issue simili

Altre issue su Testing & QA

Ricevi le nuove issue nella tua casella

Un breve riepilogo di issue GitHub adatte ai principianti.