From f42ab010fa9738bebd0eca2f426213f7e75c47db Mon Sep 17 00:00:00 2001 From: Tim Otten Date: Fri, 31 Jul 2015 16:58:06 -0700 Subject: [PATCH] CRM_Core_BAO_ActionScheduleTest - Fix racy test --- .../CRM/Core/BAO/ActionScheduleTest.php | 21 +++++++++++++------ 1 file changed, 15 insertions(+), 6 deletions(-) diff --git a/tests/phpunit/CRM/Core/BAO/ActionScheduleTest.php b/tests/phpunit/CRM/Core/BAO/ActionScheduleTest.php index 0973cbd33d..be1d3cba16 100755 --- a/tests/phpunit/CRM/Core/BAO/ActionScheduleTest.php +++ b/tests/phpunit/CRM/Core/BAO/ActionScheduleTest.php @@ -1330,12 +1330,21 @@ class CRM_Core_BAO_ActionScheduleTest extends CiviUnitTestCase { // Assert the timestamp as of when the emails of respective three reminders as configured // 2 weeks before, on and 1 day after MED, are sent - $this->assertEquals('2012-06-01 01:00:00', - CRM_Core_DAO::getFieldValue('CRM_Core_DAO_ActionLog', $actionScheduleBefore->id, 'action_date_time', 'action_schedule_id', TRUE)); - $this->assertEquals('2012-06-15 00:00:00', - CRM_Core_DAO::getFieldValue('CRM_Core_DAO_ActionLog', $actionScheduleOn->id, 'action_date_time', 'action_schedule_id', TRUE)); - $this->assertEquals('2012-06-16 01:00:00', - CRM_Core_DAO::getFieldValue('CRM_Core_DAO_ActionLog', $actionScheduleAfter->id, 'action_date_time', 'action_schedule_id', TRUE)); + $this->assertApproxEquals( + strtotime('2012-06-01 01:00:00'), + strtotime(CRM_Core_DAO::getFieldValue('CRM_Core_DAO_ActionLog', $actionScheduleBefore->id, 'action_date_time', 'action_schedule_id', TRUE)), + 3 // Variation in test execution time. + ); + $this->assertApproxEquals( + strtotime('2012-06-15 00:00:00'), + strtotime(CRM_Core_DAO::getFieldValue('CRM_Core_DAO_ActionLog', $actionScheduleOn->id, 'action_date_time', 'action_schedule_id', TRUE)), + 3 // Variation in test execution time. + ); + $this->assertApproxEquals( + strtotime('2012-06-16 01:00:00'), + strtotime(CRM_Core_DAO::getFieldValue('CRM_Core_DAO_ActionLog', $actionScheduleAfter->id, 'action_date_time', 'action_schedule_id', TRUE)), + 3 // Variation in test execution time. + ); //extend MED to 2 weeks after the current MED (that may signifies as membership renewal activity) // and lets assert as of when the new set of reminders will be sent against their respective Schedule Reminders(SR) -- 2.25.1