Hacktoberfest 2026: le issue che i maintainer hanno segnato per ottobre, aperte e adatte ai principianti. Sfoglia le issue Hacktoberfest

seeResponseCodeIs no longer produce ComparisonFailure object when failed

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

Nessuno ha ancora preso questa issue.

Valutazione

Difficoltà
3/5
Tempo stimato
1-2 giorni
Idoneità per principianti
42/100
Tipo di issue
Bug
Chiarezza
Abbastanza chiara
Stato di attività
Ferma
Stack tecnologico
php
Ambito
testing

Direzione di ricerca

Partite dall’entry point seeResponseCodeIs e confrontate il suo comportamento delle assertion PHPUnit con le implementazioni referenziate di IsIdentical e IsEqual. Riproducete l’assertion fallita 200 contro 401, quindi verificate che la ExpectationFailedException risultante esponga nuovamente una ComparisonFailure il cui valore effettivo è 401.

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

Descrizione

Hello,

Since 2.x, method seeResponseCodeIs is no longer generating a object ComparisonFailure within the exception when the assertion failed.

This change come from the usage of assertSame instead of assertEquals.

Based on PHPUnit, assertSame generate a ComparisonFailure object only if both values are a string or an array (https://github.com/sebastianbergmann/phpunit/blob/0c37cbcbfdc72425c984460660ac4514918b112e/src/Framework/Constraint/IsIdentical.php#L55 while assertEquals always generate it (https://github.com/sebastianbergmann/phpunit/blob/0c37cbcbfdc72425c984460660ac4514918b112e/src/Framework/Constraint/Equality/IsEqual.php)

Because of this change, the following code no longer works :

try {
    $this->seeResponseCodeIs(200);
} catch (\PHPUnit\Framework\ExpectationFailedException $e) {
    if ($e->getComparisonFailure()->getActual() === 401) {
        // Doing something else
    }
}

Is there a reason to use assertSame instead of assertEquals in this case ? Do you think it could be changed ?

Thank you for your time.

Lingua principale
PHP
Stelle
87
Fork
20
Metriche di merge delle PR
Nessuna PR unita negli ultimi 30g

Guida per i contributori

Nessuna guida per i contributori indicizzata per questo repository

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 Codeception/lib-innerbrowser

Tutte le issue di Codeception/lib-innerbrowser

Issue simili

Altre issue su PHP

Ricevi le nuove issue nella tua casella

Un breve riepilogo di issue GitHub adatte ai principianti.