j0k3r / graby

Graby helps you extract article content from web pages
MIT License
362 stars 73 forks source link

Date tests failing locally #318

Closed jtojnar closed 1 year ago

jtojnar commented 1 year ago

The test suite fails for me locally:

There were 5 failures:

1) Tests\Graby\Extractor\ContentExtractorTest::testExtractDate with data set #0 ('//time[@pubdate or @pubDate]', '<html><time pubdate="2015-01-.../html>', '2015-01-01T00:00:00+01:00')
Failed asserting that two strings are identical.
--- Expected
+++ Actual
@@ @@
-'2015-01-01T00:00:00+01:00'
+'2015-01-01T00:00:00+00:00'

/home/jtojnar/Projects/graby/tests/Extractor/ContentExtractorTest.php:347

2) Tests\Graby\Extractor\ContentExtractorTest::testExtractDate with data set #2 ('//date[@pubdate or @pubDate]', '<html><time pubdate="2015-01-.../html>', '2015-01-01T00:00:00+01:00')
Failed asserting that two strings are identical.
--- Expected
+++ Actual
@@ @@
-'2015-01-01T00:00:00+01:00'
+'2015-01-01T00:00:00+00:00'

/home/jtojnar/Projects/graby/tests/Extractor/ContentExtractorTest.php:347

3) Tests\Graby\Extractor\ContentExtractorTest::testExtractDate with data set #3 ('string(//time[@pubdate or @pubDate])', '<html><time pubdate="2015-01-.../html>', '2015-01-01T00:00:00+01:00')
Failed asserting that two strings are identical.
--- Expected
+++ Actual
@@ @@
-'2015-01-01T00:00:00+01:00'
+'2015-01-01T00:00:00+00:00'

/home/jtojnar/Projects/graby/tests/Extractor/ContentExtractorTest.php:347

4) Tests\Graby\Extractor\ContentExtractorTest::testExtractHNews with data set #0 ('<html><body><div class="hentr.../html>', '<p class="entry-content">this...ow</p>', array('hello !', '2015-01-01T00:00:00+01:00', array('hello !')))
Failed asserting that two strings are identical.
--- Expected
+++ Actual
@@ @@
-'2015-01-01T00:00:00+00:00'
+'2015-01-01T00:00:00+01:00'

/home/jtojnar/Projects/graby/tests/Extractor/ContentExtractorTest.php:610

5) Tests\Graby\Extractor\ContentExtractorTest::testJsonLdDateArray
Failed asserting that two strings are identical.
--- Expected
+++ Actual
@@ @@
-'2014-05-29T00:00:00+02:00'
+'2014-05-29T00:00:00+00:00'

/home/jtojnar/Projects/graby/tests/Extractor/ContentExtractorTest.php:1052

I can work around this with but it will probably fail again once daylight saving starts again or something:

--- a/phpunit.xml
+++ b/phpunit.xml
@@ -19,6 +19,7 @@
     <php>
         <!-- until all deps are compatible with PHP 8.1 -->
         <env name="SYMFONY_DEPRECATIONS_HELPER" value="weak" />
+        <ini name="date.timezone" value="Europe/Berlin"/>
     </php>

     <filter>

Maybe we should run the tests in UTC?

j0k3r commented 1 year ago

Maybe we should run the tests in UTC?

TimeZone is already forced during tests and they aren't failing.

But yes my local TZ is forced to the same value. Did your PHP config run on UTC?

I maybe prefer the workaround in the phpunit.xml (and maybe we can then remove the forced value in GA) to avoid forcing people to use UTC TZ locally to run test. What do you think?