From 659e3f525ec5b11b1473317ae6bb36c82be10dfa Mon Sep 17 00:00:00 2001 From: eileen Date: Fri, 7 Jun 2019 12:37:24 +1200 Subject: [PATCH] Skip testGetFromTo on date transition This avoids fails when the expectations were calculated right at the end of a day but then are compared with the new day's values. Results in this case look like CRM_Report_FormTest::testGetFromTo with data set #1 ('20190606000000', '20190606235959', 'this.day', '', '') fail on data set [ this.day , , ]. Local php time is 2019-06-07 00:00:13 and mysql time is 2019-06-07 00:00:13 Failed asserting that two arrays are equal. --- Expected +++ Actual @@ @@ Array ( - 0 => '20190606000000' - 1 => '20190606235959' + 0 => '20190607000000' + 1 => '20190607235959' --- tests/phpunit/CRM/Report/FormTest.php | 14 +++++++++----- 1 file changed, 9 insertions(+), 5 deletions(-) diff --git a/tests/phpunit/CRM/Report/FormTest.php b/tests/phpunit/CRM/Report/FormTest.php index bed5587d5924..5d0b0313a4e6 100644 --- a/tests/phpunit/CRM/Report/FormTest.php +++ b/tests/phpunit/CRM/Report/FormTest.php @@ -74,14 +74,18 @@ public function fromToData() { * Test that getFromTo returns the correct dates. * * @dataProvider fromToData - * @param $expectedFrom - * @param $expectedTo - * @param $relative - * @param $from - * @param $to + * + * @param string $expectedFrom + * @param string $expectedTo + * @param string $relative + * @param string $from + * @param string $to */ public function testGetFromTo($expectedFrom, $expectedTo, $relative, $from, $to) { $obj = new CRM_Report_Form(); + if (date('H-i') === '00:00') { + $this->markTestIncomplete('The date might have changed since the dataprovider was called. Skip to avoid flakiness'); + } list($calculatedFrom, $calculatedTo) = $obj->getFromTo($relative, $from, $to); $this->assertEquals([$expectedFrom, $expectedTo], [$calculatedFrom, $calculatedTo], "fail on data set [ $relative , $from , $to ]. Local php time is " . date('Y-m-d H:i:s') . ' and mysql time is ' . CRM_Core_DAO::singleValueQuery('SELECT NOW()')); }