当前位置: 首页>>代码示例>>PHP>>正文


PHP CRM_Utils_Time::setTime方法代码示例

本文整理汇总了PHP中CRM_Utils_Time::setTime方法的典型用法代码示例。如果您正苦于以下问题:PHP CRM_Utils_Time::setTime方法的具体用法?PHP CRM_Utils_Time::setTime怎么用?PHP CRM_Utils_Time::setTime使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在CRM_Utils_Time的用法示例。


在下文中一共展示了CRM_Utils_Time::setTime方法的7个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: testSequence

 public function testSequence()
 {
     $actStatuses = array_flip(\CRM_Core_PseudoConstant::activityStatus('name'));
     $caseStatuses = array_flip(\CRM_Case_PseudoConstant::caseStatus('name'));
     // Create case; schedule first activity
     \CRM_Utils_Time::setTime('2013-11-30 01:00:00');
     $case = $this->callAPISuccess('case', 'create', $this->_params);
     $analyzer = new \Civi\CCase\Analyzer($case['id']);
     $this->assertEquals($caseStatuses['Open'], self::ag($analyzer->getCase(), 'status_id'));
     $this->assertApproxTime('2013-11-30 01:00:00', self::ag($analyzer->getSingleActivity('Medical evaluation'), 'activity_date_time'));
     $this->assertEquals($actStatuses['Scheduled'], self::ag($analyzer->getSingleActivity('Medical evaluation'), 'status_id'));
     $this->assertFalse($analyzer->hasActivity('Mental health evaluation'));
     $this->assertFalse($analyzer->hasActivity('Secure temporary housing'));
     // Edit details of first activity -- but don't finish it yet!
     \CRM_Utils_Time::setTime('2013-11-30 01:30:00');
     $this->callApiSuccess('Activity', 'create', array('id' => self::ag($analyzer->getSingleActivity('Medical evaluation'), 'id'), 'subject' => 'This is the new subject'));
     $analyzer = new \Civi\CCase\Analyzer($case['id']);
     $this->assertEquals($caseStatuses['Open'], self::ag($analyzer->getCase(), 'status_id'));
     $this->assertApproxTime('2013-11-30 01:00:00', self::ag($analyzer->getSingleActivity('Medical evaluation'), 'activity_date_time'));
     $this->assertEquals($actStatuses['Scheduled'], self::ag($analyzer->getSingleActivity('Medical evaluation'), 'status_id'));
     $this->assertFalse($analyzer->hasActivity('Mental health evaluation'));
     $this->assertFalse($analyzer->hasActivity('Secure temporary housing'));
     // Complete first activity; schedule second
     \CRM_Utils_Time::setTime('2013-11-30 02:00:00');
     $this->callApiSuccess('Activity', 'create', array('id' => self::ag($analyzer->getSingleActivity('Medical evaluation'), 'id'), 'status_id' => $actStatuses['Completed']));
     $analyzer->flush();
     $this->assertEquals($caseStatuses['Open'], self::ag($analyzer->getCase(), 'status_id'));
     $this->assertApproxTime('2013-11-30 01:00:00', self::ag($analyzer->getSingleActivity('Medical evaluation'), 'activity_date_time'));
     $this->assertEquals($actStatuses['Completed'], self::ag($analyzer->getSingleActivity('Medical evaluation'), 'status_id'));
     $this->assertApproxTime('2013-11-30 02:00:00', self::ag($analyzer->getSingleActivity('Mental health evaluation'), 'activity_date_time'));
     $this->assertEquals($actStatuses['Scheduled'], self::ag($analyzer->getSingleActivity('Mental health evaluation'), 'status_id'));
     $this->assertFalse($analyzer->hasActivity('Secure temporary housing'));
     // Complete second activity; schedule third
     \CRM_Utils_Time::setTime('2013-11-30 03:00:00');
     $this->callApiSuccess('Activity', 'create', array('id' => self::ag($analyzer->getSingleActivity('Mental health evaluation'), 'id'), 'status_id' => $actStatuses['Completed']));
     $analyzer->flush();
     $this->assertEquals($caseStatuses['Open'], self::ag($analyzer->getCase(), 'status_id'));
     $this->assertApproxTime('2013-11-30 01:00:00', self::ag($analyzer->getSingleActivity('Medical evaluation'), 'activity_date_time'));
     $this->assertEquals($actStatuses['Completed'], self::ag($analyzer->getSingleActivity('Medical evaluation'), 'status_id'));
     $this->assertApproxTime('2013-11-30 02:00:00', self::ag($analyzer->getSingleActivity('Mental health evaluation'), 'activity_date_time'));
     $this->assertEquals($actStatuses['Completed'], self::ag($analyzer->getSingleActivity('Mental health evaluation'), 'status_id'));
     $this->assertApproxTime('2013-11-30 03:00:00', self::ag($analyzer->getSingleActivity('Secure temporary housing'), 'activity_date_time'));
     $this->assertEquals($actStatuses['Scheduled'], self::ag($analyzer->getSingleActivity('Secure temporary housing'), 'status_id'));
     // Complete third activity; close case
     \CRM_Utils_Time::setTime('2013-11-30 04:00:00');
     $this->callApiSuccess('Activity', 'create', array('id' => self::ag($analyzer->getSingleActivity('Secure temporary housing'), 'id'), 'status_id' => $actStatuses['Completed']));
     $analyzer->flush();
     $this->assertApproxTime('2013-11-30 01:00:00', self::ag($analyzer->getSingleActivity('Medical evaluation'), 'activity_date_time'));
     $this->assertEquals($actStatuses['Completed'], self::ag($analyzer->getSingleActivity('Medical evaluation'), 'status_id'));
     $this->assertApproxTime('2013-11-30 02:00:00', self::ag($analyzer->getSingleActivity('Mental health evaluation'), 'activity_date_time'));
     $this->assertEquals($actStatuses['Completed'], self::ag($analyzer->getSingleActivity('Mental health evaluation'), 'status_id'));
     $this->assertApproxTime('2013-11-30 03:00:00', self::ag($analyzer->getSingleActivity('Secure temporary housing'), 'activity_date_time'));
     $this->assertEquals($actStatuses['Completed'], self::ag($analyzer->getSingleActivity('Secure temporary housing'), 'status_id'));
     $this->assertEquals($caseStatuses['Closed'], self::ag($analyzer->getCase(), 'status_id'));
     // */
 }
开发者ID:sdekok,项目名称:civicrm-core,代码行数:56,代码来源:SequenceListenerTest.php

示例2: processQueue

 /**
  * @param null $now
  * @param array $params
  *
  * @return array
  */
 static function processQueue($now = NULL, $params = array())
 {
     $now = $now ? CRM_Utils_Time::setTime($now) : CRM_Utils_Time::getTime();
     $mappings = self::getMapping();
     foreach ($mappings as $mappingID => $mapping) {
         self::buildRecipientContacts($mappingID, $now, $params);
         self::sendMailings($mappingID, $now);
     }
     $result = array('is_error' => 0, 'messages' => ts('Sent all scheduled reminders successfully'));
     return $result;
 }
开发者ID:ruchirapingale,项目名称:civicrm-core,代码行数:17,代码来源:ActionSchedule.php

示例3: testGetDocument_NewOK_UpdateFailure_CacheOK_UpdateOK

 /**
  * First download of new doc is OK.
  * The update fails (due to some bad web response).
  * The old data is retained in the cache.
  * The failure eventually expires.
  * A new update succeeds.
  *
  * @dataProvider badWebResponses
  * @param array $badWebResponse
  *   Description of a web request that returns some kind of failure.
  */
 public function testGetDocument_NewOK_UpdateFailure_CacheOK_UpdateOK($badWebResponse)
 {
     $this->assertNotEmpty($badWebResponse);
     // first try, good response
     CRM_Utils_Time::setTime('2013-03-01 10:00:00');
     $communityMessages = new CRM_Core_CommunityMessages($this->cache, $this->expectOneHttpRequest(self::$webResponses['first-valid-response']));
     $doc1 = $communityMessages->getDocument();
     $this->assertEquals('<h1>First valid response</h1>', $doc1['messages'][0]['markup']);
     $this->assertApproxEquals(strtotime('2013-03-01 10:10:00'), $doc1['expires'], self::APPROX_TIME_EQUALITY);
     // second try, $doc1 has expired; bad response; keep old data
     CRM_Utils_Time::setTime('2013-03-01 12:00:02');
     // more than 2 hours later (DEFAULT_RETRY)
     $communityMessages = new CRM_Core_CommunityMessages($this->cache, $this->expectOneHttpRequest($badWebResponse));
     $doc2 = $communityMessages->getDocument();
     $this->assertEquals('<h1>First valid response</h1>', $doc2['messages'][0]['markup']);
     $this->assertTrue($doc2['expires'] > CRM_Utils_Time::getTimeRaw());
     // third try, $doc2 hasn't expired yet; no request; keep old data
     CRM_Utils_Time::setTime('2013-03-01 12:09:00');
     $communityMessages = new CRM_Core_CommunityMessages($this->cache, $this->expectNoHttpRequest());
     $doc3 = $communityMessages->getDocument();
     $this->assertEquals('<h1>First valid response</h1>', $doc3['messages'][0]['markup']);
     $this->assertEquals($doc2['expires'], $doc3['expires']);
     // fourth try, $doc2 has expired yet; new request; replace data
     CRM_Utils_Time::setTime('2013-03-01 12:10:02');
     $communityMessages = new CRM_Core_CommunityMessages($this->cache, $this->expectOneHttpRequest(self::$webResponses['second-valid-response']));
     $doc4 = $communityMessages->getDocument();
     $this->assertEquals('<h1>Second valid response</h1>', $doc4['messages'][0]['markup']);
     $this->assertApproxEquals(strtotime('2013-03-01 12:20:02'), $doc4['expires'], self::APPROX_TIME_EQUALITY);
 }
开发者ID:sdekok,项目名称:civicrm-core,代码行数:40,代码来源:CommunityMessagesTest.php

示例4: testDefault

 /**
  * Execute the default schedule, without any special recipient selections.
  *
  * @dataProvider createTestCases
  *
  * @param string $targetDate
  * @param string $setupFuncs
  * @param array $expectMessages
  *
  * @throws \Exception
  */
 public function testDefault($targetDate, $setupFuncs, $expectMessages)
 {
     $this->targetDate = $targetDate;
     foreach (explode(' ', $setupFuncs) as $setupFunc) {
         $this->{$setupFunc}();
     }
     $this->schedule->save();
     $actualMessages = array();
     foreach ($this->cronTimes() as $time) {
         \CRM_Utils_Time::setTime($time);
         $this->callAPISuccess('job', 'send_reminder', array());
         foreach ($this->mut->getAllMessages('ezc') as $message) {
             /** @var \ezcMail $message */
             $simpleMessage = array('time' => $time, 'to' => \CRM_Utils_Array::collect('email', $message->to), 'subject' => $message->subject);
             sort($simpleMessage['to']);
             $actualMessages[] = $simpleMessage;
             $this->mut->clearMessages();
         }
     }
     $errorText = "Incorrect messages: " . print_r(array('actualMessages' => $actualMessages, 'expectMessages' => $expectMessages), 1);
     $this->assertEquals(count($expectMessages), count($actualMessages), $errorText);
     usort($expectMessages, array(__CLASS__, 'compareSimpleMsgs'));
     usort($actualMessages, array(__CLASS__, 'compareSimpleMsgs'));
     foreach ($expectMessages as $offset => $expectMessage) {
         $actualMessage = $actualMessages[$offset];
         $this->assertApproxEquals(strtotime($expectMessage['time']), strtotime($actualMessage['time']), $this->dateTolerance, $errorText);
         if (isset($expectMessage['to'])) {
             sort($expectMessage['to']);
             $this->assertEquals($expectMessage['to'], $actualMessage['to'], $errorText);
         }
         if (isset($expectMessage['subject'])) {
             $this->assertRegExp($expectMessage['subject'], $actualMessage['subject'], $errorText);
         }
     }
 }
开发者ID:konadave,项目名称:civicrm-core,代码行数:46,代码来源:AbstractMappingTest.php

示例5: assertCronRuns

 /**
  * Run a series of cron jobs and make an assertion about email deliveries.
  *
  * @param array $cronRuns
  *   array specifying when to run cron and what messages to expect; each item is an array with keys:
  *   - time: string, e.g. '2012-06-15 21:00:01'
  *   - recipients: array(array(string)), list of email addresses which should receive messages
  */
 public function assertCronRuns($cronRuns)
 {
     foreach ($cronRuns as $cronRun) {
         CRM_Utils_Time::setTime($cronRun['time']);
         $this->callAPISuccess('job', 'send_reminder', array());
         $this->mut->assertRecipients($cronRun['recipients']);
         if (array_key_exists('subjects', $cronRun)) {
             $this->mut->assertSubjects($cronRun['subjects']);
         }
         $this->mut->clearMessages();
     }
 }
开发者ID:konadave,项目名称:civicrm-core,代码行数:20,代码来源:ActionScheduleTest.php

示例6: testStealItem

 /**
  * Test that item leases can be ignored.
  *
  * @dataProvider getQueueSpecs
  * @param $queueSpec
  */
 public function testStealItem($queueSpec)
 {
     $this->queue = $this->queueService->create($queueSpec);
     $this->assertTrue($this->queue instanceof CRM_Queue_Queue);
     require_once 'CRM/Utils/Time.php';
     CRM_Utils_Time::setTime('2012-04-01 1:00:00');
     $this->queue->createItem(array('test-key' => 'a'));
     $item = $this->queue->claimItem();
     $this->assertEquals('a', $item->data['test-key']);
     $this->assertEquals(1, $this->queue->numberOfItems());
     // forget to release
     // haven't reached expiration yet, so claimItem fails
     CRM_Utils_Time::setTime('2012-04-01 1:59:00');
     $item2 = $this->queue->claimItem();
     $this->assertEquals(FALSE, $item2);
     // but stealItem works
     $item3 = $this->queue->stealItem();
     $this->assertEquals('a', $item3->data['test-key']);
     $this->assertEquals(1, $this->queue->numberOfItems());
     $this->queue->deleteItem($item3);
     $this->assertEquals(0, $this->queue->numberOfItems());
 }
开发者ID:rajeshrhino,项目名称:civicrm-core,代码行数:28,代码来源:QueueTest.php

示例7: assertCronRuns

 /**
  * Run a series of cron jobs and make an assertion about email deliveries
  *
  * @param $cronRuns
  *
  * @internal param array $jobSchedule specifying when to run cron and what messages to expect; each item is an array with keys:
  *  - time: string, e.g. '2012-06-15 21:00:01'
  *  - recipients: array(array(string)), list of email addresses which should receive messages
  */
 function assertCronRuns($cronRuns)
 {
     foreach ($cronRuns as $cronRun) {
         CRM_Utils_Time::setTime($cronRun['time']);
         $result = civicrm_api('job', 'send_reminder', array('version' => 3));
         $this->assertAPISuccess($result);
         $this->mut->assertRecipients($cronRun['recipients']);
         $this->mut->clearMessages();
     }
 }
开发者ID:prashantgajare,项目名称:civicrm-core,代码行数:19,代码来源:ActionScheduleTest.php


注:本文中的CRM_Utils_Time::setTime方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。