sebastianbergmann/phpunit — Issue #406: Useless failure description for assertStringMatchesFormat*()
Author: sebastianbergmann
Created: 2011-11-12 08:41:20+00:00
State: open
Labels: bug

Since the introduction of the comparator framework, `assertStringMatchesFormat()` and `assertStringMatchesFormatFile()` produce useless failure descriptions.

`StringMatchesFormatFileTest.php`

assertStringMatchesFormatFile('expected.txt', '...BAR...');
}
}

`expected.txt`

%sFOO%d

Output with PHPUnit 3.5
-----------------------

➜ ~ phpunit StringMatchesFormatFileTest
PHPUnit @package_version@ by Sebastian Bergmann.

F

Time: 0 seconds, Memory: 4.00Mb

There was 1 failure:

1) StringMatchesFormatFileTest::testFailure
Failed asserting that two strings are equal.
--- Expected
+++ Actual
@@ @@
-%sFOO%d
-
-
+...BAR...

/home/sb/StringMatchesFormatFileTest.php:6

FAILURES!
Tests: 1, Assertions: 2, Failures: 1.

Output with PHPUnit 3.6
-----------------------

➜ ~ phpunit StringMatchesFormatFileTest
PHPUnit @package_version@ by Sebastian Bergmann.

F

Time: 0 seconds, Memory: 3.50Mb

There was 1 failure:

1) StringMatchesFormatFileTest::testFailure
Failed asserting that '...BAR...' matches PCRE pattern "/^[^\r\n]+FOO\d+

$/s".

/home/sb/StringMatchesFormatFileTest.php:6

FAILURES!
Tests: 1, Assertions: 2, Failures: 1.