@@ -481,23 +481,29 @@ public static function matchFile(string $file, $actual, string $description = nu
481481 throw new \Exception ("Unable to read file ' $ file'. " );
482482
483483 } elseif (!is_scalar ($ actual )) {
484- self ::fail (self ::describe ('%1 should match %2 ' , $ description ), $ actual , $ pattern );
484+ self ::fail (self ::describe ('%1 should match %2 ' , $ description ), $ actual , $ pattern, null , basename ( $ file ) );
485485
486486 } elseif (!self ::isMatching ($ pattern , $ actual )) {
487487 if (self ::$ expandPatterns ) {
488488 [$ pattern , $ actual ] = self ::expandMatchingPatterns ($ pattern , $ actual );
489489 }
490- self ::fail (self ::describe ('%1 should match %2 ' , $ description ), $ actual , $ pattern );
490+ self ::fail (self ::describe ('%1 should match %2 ' , $ description ), $ actual , $ pattern, null , basename ( $ file ) );
491491 }
492492 }
493493
494494
495495 /**
496496 * Assertion that fails.
497497 */
498- public static function fail (string $ message , $ actual = null , $ expected = null , \Throwable $ previous = null ): void
499- {
498+ public static function fail (
499+ string $ message ,
500+ $ actual = null ,
501+ $ expected = null ,
502+ \Throwable $ previous = null ,
503+ string $ outputName = null
504+ ): void {
500505 $ e = new AssertException ($ message , $ expected , $ actual , $ previous );
506+ $ e ->outputName = $ outputName ;
501507 if (self ::$ onFailure ) {
502508 (self ::$ onFailure )($ e );
503509 } else {
0 commit comments