jbroadway/analog

Unit tests may fail

trasher opened this issue · 1 comments

I execute unit tests on Analog during the construction of the package for Fedora; a build system will ran the tests, and the build will fail if unit tests are not ok.

Unit tests ran well almost all the time, I had once the following:
+ phpunit tests
PHPUnit 3.7.9 by Sebastian Bergmann.
Configuration read from /builddir/build/BUILD/analog-1.0.0-git876d8a3bb/phpunit.xml.dist
^[[41;37mF^[[0m^[[36;1mS^[[0m^[[36;1mS^[[0m
Time: 0 seconds, Memory: 3.00Mb
There was 1 failure:
1) AnalogTest::test_default
Failed asserting that two strings are equal.
--- Expected
+++ Actual
@@ @@
-'localhost - 2012-12-30 12:15:21 - 3 - Foo
+'localhost - 2012-12-30 12:15:20 - 3 - Foo
'

Not a big issue, but that would cause rejects from the build system, I had to disable tests (well, I actually make them quiet on error).

Maybe a solution would be to use something like:
$this->assertStringMatchesFormat ("localhost - %d-%d-%d %d:%d:%d - 3 - Foo\n", file_get_contents (Analog::handler ());

You can find a git formatted patch with this change at:
http://odysseus.x-tnd.be/fedora/php-Analog/0001-Tests-may-fail-on-seconds.patch

Thanks for the patch!