google-listings-and-ads
google-listings-and-ads copied to clipboard
test_disable_promotion failing locally
Describe the bug:
When running the GLA unit tests locally test_disable_promotion
in WCCouponAdapterTest
is failing because of unexpected datetimes. Tests are all passing on GH so this is not a high-priority issue but may need to be investigated further.
Expected behavior:
Tests should pass regardless of the environment they are run in.
I'm not able to reproduce this failure, although it might be related to a specific time of day since it uses gmdate( DATE_ATOM )
.
However one thing I noticed is that all data providers (search for @dataProvider) will run regardless of what the filter is set to. For this specific test that won't make too much difference but it will take longer to run because it creates a whole host of test products. A better way to run just that specific test is:
vendor/bin/phpunit tests/Unit/Coupon/WCCouponAdapterTest.php --filter=test_disable_promotion
There was a recent failure of this same test, although there was a difference of only 1 second: https://github.com/woocommerce/google-listings-and-ads/actions/runs/10562298192/job/29259970597
I haven't looked into all the details, but it seems using gmdate( DATE_ATOM )
twice could potentially be a different timestamp then when the actual code is run. Should find a better way to compare those dates, or use a generated date for the test data, so we can confirm it's always the same.