(This is the first time when I'm testing with phpunit command line tool so I may be wrong)

On fresh D8 install (Standard profile) I'm running:

$ cd core
$ ./vendor/bin/phpunit

Here's the output:

Warning: date_default_timezone_get(): 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 'Europe/Helsinki' for 'EEST/3.0/DST' instead in /var/www/html/core/tests/Drupal/Tests/Component/Datetime/DateTimePlusTest.php on line 291
PHPUnit 3.7.21 by Sebastian Bergmann.

Configuration read from /var/www/html/core/phpunit.xml.dist

......FFFF.....EEEEEEEEE....E..................................  63 / 557 ( 11%)
............................................................... 126 / 557 ( 22%)
............................................................... 189 / 557 ( 33%)
............................................................... 252 / 557 ( 45%)
............................................................... 315 / 557 ( 56%)
............................................................... 378 / 557 ( 67%)
............................................................... 441 / 557 ( 79%)
............................................................... 504 / 557 ( 90%)
.....................................................

Time: 2 seconds, Memory: 45.50Mb

There were 10 errors:

1) Drupal\Tests\Component\Datetime\DateTimePlusTest::testDateFormat with data set #0 ('2009', NULL, 'Y', 'Y', '2009')
date_default_timezone_get(): 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 'Europe/Helsinki' for 'EEST/3.0/DST' instead

/var/www/html/core/lib/Drupal/Component/Datetime/DateTimePlus.php:264
/var/www/html/core/lib/Drupal/Component/Datetime/DateTimePlus.php:160
/var/www/html/core/tests/Drupal/Tests/Component/Datetime/DateTimePlusTest.php:129

2) Drupal\Tests\Component\Datetime\DateTimePlusTest::testDateFormat with data set #1 ('2009-10', NULL, 'Y-m', 'Y-m', '2009-10')
date_default_timezone_get(): 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 'Europe/Helsinki' for 'EEST/3.0/DST' instead

/var/www/html/core/lib/Drupal/Component/Datetime/DateTimePlus.php:264
/var/www/html/core/lib/Drupal/Component/Datetime/DateTimePlus.php:160
/var/www/html/core/tests/Drupal/Tests/Component/Datetime/DateTimePlusTest.php:129

3) Drupal\Tests\Component\Datetime\DateTimePlusTest::testDateFormat with data set #2 ('T10:30:00', NULL, '\\TH:i:s', 'H:i:s', '10:30:00')
date_default_timezone_get(): 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 'Europe/Helsinki' for 'EEST/3.0/DST' instead

/var/www/html/core/lib/Drupal/Component/Datetime/DateTimePlus.php:264
/var/www/html/core/lib/Drupal/Component/Datetime/DateTimePlus.php:160
/var/www/html/core/tests/Drupal/Tests/Component/Datetime/DateTimePlusTest.php:129

4) Drupal\Tests\Component\Datetime\DateTimePlusTest::testDateFormat with data set #3 ('10:30:00', NULL, 'H:i:s', 'H:i:s', '10:30:00')
date_default_timezone_get(): 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 'Europe/Helsinki' for 'EEST/3.0/DST' instead

/var/www/html/core/lib/Drupal/Component/Datetime/DateTimePlus.php:264
/var/www/html/core/lib/Drupal/Component/Datetime/DateTimePlus.php:160
/var/www/html/core/tests/Drupal/Tests/Component/Datetime/DateTimePlusTest.php:129

5) Drupal\Tests\Component\Datetime\DateTimePlusTest::testInvalidDates with data set #0 ('23 abc 2012', NULL, 'd M Y', '23 abc 2012 contains an invalid month name and did not produce errors.')
date_default_timezone_get(): 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 'Europe/Helsinki' for 'EEST/3.0/DST' instead

/var/www/html/core/lib/Drupal/Component/Datetime/DateTimePlus.php:264
/var/www/html/core/lib/Drupal/Component/Datetime/DateTimePlus.php:160
/var/www/html/core/tests/Drupal/Tests/Component/Datetime/DateTimePlusTest.php:149

6) Drupal\Tests\Component\Datetime\DateTimePlusTest::testInvalidDates with data set #1 ('0000-00-00T45:30:00', NULL, 'Y-m-d\\TH:i:s', '0000-00-00T45:30:00 contains an invalid hour and did not produce errors.')
date_default_timezone_get(): 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 'Europe/Helsinki' for 'EEST/3.0/DST' instead

/var/www/html/core/lib/Drupal/Component/Datetime/DateTimePlus.php:264
/var/www/html/core/lib/Drupal/Component/Datetime/DateTimePlus.php:160
/var/www/html/core/tests/Drupal/Tests/Component/Datetime/DateTimePlusTest.php:149

7) Drupal\Tests\Component\Datetime\DateTimePlusTest::testInvalidDates with data set #2 ('0000-00-99T05:30:00', NULL, 'Y-m-d\\TH:i:s', '0000-00-99T05:30:00 contains an invalid day and did not produce errors.')
date_default_timezone_get(): 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 'Europe/Helsinki' for 'EEST/3.0/DST' instead

/var/www/html/core/lib/Drupal/Component/Datetime/DateTimePlus.php:264
/var/www/html/core/lib/Drupal/Component/Datetime/DateTimePlus.php:160
/var/www/html/core/tests/Drupal/Tests/Component/Datetime/DateTimePlusTest.php:149

8) Drupal\Tests\Component\Datetime\DateTimePlusTest::testInvalidDates with data set #3 ('0000-75-00T15:30:00', NULL, 'Y-m-d\\TH:i:s', '0000-75-00T15:30:00 contains an invalid month and did not produce errors.')
date_default_timezone_get(): 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 'Europe/Helsinki' for 'EEST/3.0/DST' instead

/var/www/html/core/lib/Drupal/Component/Datetime/DateTimePlus.php:264
/var/www/html/core/lib/Drupal/Component/Datetime/DateTimePlus.php:160
/var/www/html/core/tests/Drupal/Tests/Component/Datetime/DateTimePlusTest.php:149

9) Drupal\Tests\Component\Datetime\DateTimePlusTest::testInvalidDates with data set #4 ('11-08-01T15:30:00', NULL, 'Y-m-d\\TH:i:s', '11-08-01T15:30:00 contains an invalid year and did not produce errors.')
date_default_timezone_get(): 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 'Europe/Helsinki' for 'EEST/3.0/DST' instead

/var/www/html/core/lib/Drupal/Component/Datetime/DateTimePlus.php:264
/var/www/html/core/lib/Drupal/Component/Datetime/DateTimePlus.php:160
/var/www/html/core/tests/Drupal/Tests/Component/Datetime/DateTimePlusTest.php:149

10) Drupal\Tests\Component\Datetime\DateTimePlusTest::testDateTimezone with data set #0 ('2007-01-31 21:00:00', NULL, 'Europe/Helsinki', 'DateTimePlus uses the system timezone when there is no site timezone.')
date_default_timezone_get(): 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 'Europe/Helsinki' for 'EEST/3.0/DST' instead

/var/www/html/core/lib/Drupal/Component/Datetime/DateTimePlus.php:264
/var/www/html/core/lib/Drupal/Component/Datetime/DateTimePlus.php:160
/var/www/html/core/tests/Drupal/Tests/Component/Datetime/DateTimePlusTest.php:169

--


There were 4 failures:

1) Drupal\Tests\Component\Datetime\DateTimePlusTest::testDates with data set #6 (array(2010, 2, 28), 'America/Chicago', '2010-02-28T00:00:00-06:00')
Test new DateTimePlus(array (
  'year' => 2010,
  'month' => 2,
  'day' => 28,
), America/Chicago): should be 2010-02-28T00:00:00-06:00, found .
Failed asserting that null matches expected '2010-02-28T00:00:00-06:00'.

/var/www/html/core/tests/Drupal/Tests/Component/Datetime/DateTimePlusTest.php:50

2) Drupal\Tests\Component\Datetime\DateTimePlusTest::testDates with data set #7 (array(2010, 2, 28, 10), 'America/Chicago', '2010-02-28T10:00:00-06:00')
Test new DateTimePlus(array (
  'year' => 2010,
  'month' => 2,
  'day' => 28,
  'hour' => 10,
), America/Chicago): should be 2010-02-28T10:00:00-06:00, found .
Failed asserting that null matches expected '2010-02-28T10:00:00-06:00'.

/var/www/html/core/tests/Drupal/Tests/Component/Datetime/DateTimePlusTest.php:50

3) Drupal\Tests\Component\Datetime\DateTimePlusTest::testDates with data set #8 (array(2010, 2, 28), 'Europe/Berlin', '2010-02-28T00:00:00+01:00')
Test new DateTimePlus(array (
  'year' => 2010,
  'month' => 2,
  'day' => 28,
), Europe/Berlin): should be 2010-02-28T00:00:00+01:00, found .
Failed asserting that null matches expected '2010-02-28T00:00:00+01:00'.

/var/www/html/core/tests/Drupal/Tests/Component/Datetime/DateTimePlusTest.php:50

4) Drupal\Tests\Component\Datetime\DateTimePlusTest::testDates with data set #9 (array(2010, 2, 28, 10), 'Europe/Berlin', '2010-02-28T10:00:00+01:00')
Test new DateTimePlus(array (
  'year' => 2010,
  'month' => 2,
  'day' => 28,
  'hour' => 10,
), Europe/Berlin): should be 2010-02-28T10:00:00+01:00, found .
Failed asserting that null matches expected '2010-02-28T10:00:00+01:00'.

/var/www/htmlvar/www/html/core/tests/Drupal/Tests/Component/Datetime/DateTimePlusTest.php:50

FAILURES!
Tests: 557, Assertions: 1125, Failures: 4, Errors: 10.
Support from Acquia helps fund testing for Drupal Acquia logo

Comments

Berdir’s picture

Works fine for me, but there are open issues about the intl extension, maybe it's related to that?

#2000384: php-intl module causes problems with Date and Time fields when editing Basic Page

alexpott’s picture

alexpott’s picture

but also its not much of a unit test if the php environment is having this effect... perhaps setUp() should call date_default_timezone_set to ensure we're all testing the same thing?

ParisLiakos’s picture

or maybe in bootstrap.php where we do setlocale() ? i would be fine with either, since this wont be the only test doing date related stuff

claudiu.cristea’s picture

I see no intl module

$ php -m
[PHP Modules]
bcmath
bz2
calendar
Core
ctype
curl
date
dba
dom
ereg
exif
fileinfo
filter
ftp
gd
hash
iconv
json
ldap
libxml
mbstring
mysql
mysqli
mysqlnd
odbc
openssl
pcre
PDO
pdo_mysql
pdo_pgsql
pdo_sqlite
pgsql
Phar
posix
readline
Reflection
session
shmop
SimpleXML
snmp
soap
sockets
SPL
SQLite
sqlite3
standard
sysvmsg
sysvsem
sysvshm
tidy
tokenizer
wddx
xml
xmlreader
xmlrpc
xmlwriter
xsl
zip
zlib

[Zend Modules]
claudiu.cristea’s picture

Status: Active » Closed (works as designed)

@alexpott, those clues were pointing to my error.

Sorry everybody, false alarm :)

In fact on my Mac I'm using MAMP. For some reason, php it's also installed. From cli, running $ php is using the system PHP, not MAMP PHP and that one have no php.ini. This is poping up the error. I setup the environment to use the correct PHP CLI and now phpunit runs without any error.

ParisLiakos’s picture

Status: Closed (works as designed) » Needs review
FileSize
439 bytes

i reopen this, because i get it everytime i am on a different dev enviroment, mostly because Debian's php.ini comes with an empty date.timezone in its php.ini
so, while manually setting it, might be a good thing, this is annoying and we shouldnt force anyone to face all those warnings.
it also brings consistency to tests, like setlocale

Berdir’s picture

Status: Needs review » Needs work
@@ -25,3 +25,7 @@
+// Set the default timezone. While this doesnt cause any tests to fail, PHP
+// complains if it is not set in 'date.timezone' of php.ini.

doesn't.

*in* php.ini?

Sorry :)

Should only set it if there's no default timezone? Or should we explicitly define that tests should run in UTC, always?

ParisLiakos’s picture

i dont see anything bad, with setting every test on UTC..in contrast it makes all test consistent between enviroments.
i tried only setting it up only for the DateTimePlusTest::setUp but it spits a warning on the very start..that way there are no warnings:)

ParisLiakos’s picture

Status: Needs work » Needs review
FileSize
551 bytes
434 bytes

You can observe those warnings here https://qa.drupal.org/pifr/test/600303#tabset-tab-4
seems this is not a problem for PHP5.3

Fixed #8

Berdir’s picture

Status: Needs review » Reviewed & tested by the community
Issue tags: +PHP 5.4

Not sure if the test bot is just configured differently or if this only happens for PHP 5.4, but I think it makes sense to configure this and avoid different environments for unit tests anyway.

alexpott’s picture

Status: Reviewed & tested by the community » Fixed

I agree

Committed bc58322 and pushed to 8.x. Thanks!

Automatically closed -- issue fixed for 2 weeks with no activity.

Anonymous’s picture

Issue summary: View changes

code fix