mercredi 8 août 2018

PHPUnit: Is there something like "assertExistsNotNull"?

I recently detected the following problem:

self::assertNull($someArray[$someIndex]);

If $someIndex is not an existing index of $someArray, $someArray[$someIndex] will evaluate to null and assertNull(null) will say everything is okay. So basically PHPUnit is hiding a problem.

Is there something like

self::assertExistsNotNull($someArray[$someIndex]);

which only is true if $someArray[$someIndex] exists and is not null?

Aucun commentaire:

Enregistrer un commentaire