Skip to content

Commit

Permalink
Skip testGetFromTo on date transition
Browse files Browse the repository at this point in the history
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'
  • Loading branch information
eileenmcnaughton committed Jun 7, 2019
1 parent 4741274 commit 659e3f5
Showing 1 changed file with 9 additions and 5 deletions.
14 changes: 9 additions & 5 deletions tests/phpunit/CRM/Report/FormTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -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()'));
}
Expand Down

0 comments on commit 659e3f5

Please sign in to comment.