InterNations / http-mock

Mock HTTP requests on the server side in your PHP unit tests
http://www.internations.org
MIT License
391 stars 62 forks source link

version 0.7.8. http-mock issues warnings because timezone and breaks phpunit tests #36

Open JoeZ99 opened 7 years ago

JoeZ99 commented 7 years ago

when trying to run tests with http-mock, there is this warning

PHPUnit 4.8.29 by Sebastian Bergmann and contributors.

.F.................................

Time: 203 ms, Memory: 10.00MB

There was 1 failure:

1) Doofinder\Api\Test\Management\ClientTest::testDummy
HTTP mock server standard error output should be empty
Failed asserting that two strings are identical.
--- Expected
+++ Actual
@@ @@
+[Thu Dec  1 10:37:39 2016] PHP Warning:  DateTime::createFromFormat(): It is not safe to rely on the system's timezone settings. You are *required* to use the date.timezone setting or the date_default_timezone_set() function. In case you used any of those methods and you are still getting this warning, you most likely misspelled the timezone identifier. We selected the timezone 'UTC' for now, but please set date.timezone to select your timezone. in /home/jzarate/havet/php-doofinder/vendor/symfony/http-foundation/Response.php on line 333
+[Thu Dec  1 10:37:39 2016] PHP Warning:  DateTime::createFromFormat(): It is not safe to rely on the system's timezone settings. You are *required* to use the date.timezone setting or the date_default_timezone_set() function. In case you used any of those methods and you are still getting this warning, you most likely misspelled the timezone identifier. We selected the timezone 'UTC' for now, but please set date.timezone to select your timezone. in /home/jzarate/havet/php-doofinder/vendor/symfony/http-foundation/Response.php on line 333

/home/jzarate/havet/php-doofinder/vendor/internations/http-mock/src/InterNations/Component/HttpMock/PHPUnit/HttpMockTrait.php:56
/home/jzarate/havet/php-doofinder/src/Test/Management/ClientTest.php:42

it's related to not having timezone defined.

Since http-mock starts its own process, nothing I do on phpunit tests (like disabling warnings, setting timezone, etc..) will fix this (http-mock runs in its own process)

I haven't found a way to pass php init options or the like to http-mock's process, phpunit is unusable

pusherman commented 7 years ago

set date.timezone in your php.ini

lstrojny commented 7 years ago

That’s indeed unfortunate. The only idea I would have is to either throw an exception if date.timezone is not defined or set it to UTC. Comments?