SearchTest.php 2.18 KB
Newer Older
eileen's avatar
eileen committed
1
2
3
4
5
6
7
8
9
10
11
<?php

/**
 *  Include dataProvider for tests
 * @group headless
 */
class CRM_Activity_Form_SearchTest extends CiviUnitTestCase {

  public function setUp() {
    parent::setUp();
    $this->individualID = $this->individualCreate();
eileen's avatar
eileen committed
12
13
14
15
    $this->contributionCreate([
      'contact_id' => $this->individualID,
      'receive_date' => '2017-01-30',
    ]);
eileen's avatar
eileen committed
16
17
18
  }

  public function tearDown() {
eileen's avatar
eileen committed
19
    $tablesToTruncate = [
eileen's avatar
eileen committed
20
21
      'civicrm_activity',
      'civicrm_activity_contact',
eileen's avatar
eileen committed
22
    ];
eileen's avatar
eileen committed
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
    $this->quickCleanup($tablesToTruncate);
  }

  /**
   *  Test submitted the search form.
   */
  public function testSearch() {

    $form = new CRM_Activity_Form_Search();
    $_SERVER['REQUEST_METHOD'] = 'GET';
    $form->controller = new CRM_Activity_Controller_Search();
    $form->preProcess();
    $form->postProcess();
    $qfKey = $form->controller->_key;
    $rows = $form->controller->get('rows');
eileen's avatar
eileen committed
38
39
    $this->assertEquals([
      [
eileen's avatar
eileen committed
40
41
42
43
44
45
46
47
48
49
50
51
52
        'contact_id' => '3',
        'contact_type' => '<a href="/index.php?q=civicrm/profile/view&amp;reset=1&amp;gid=7&amp;id=3&amp;snippet=4" class="crm-summary-link"><div class="icon crm-icon Individual-icon"></div></a>',
        'sort_name' => 'Anderson, Anthony',
        'display_name' => 'Mr. Anthony Anderson II',
        'activity_id' => '1',
        'activity_date_time' => '2017-01-30 00:00:00',
        'activity_status_id' => '2',
        'activity_status' => 'Completed',
        'activity_subject' => '$ 100.00 - SSF',
        'source_record_id' => '1',
        'activity_type_id' => '6',
        'activity_type' => 'Contribution',
        'activity_is_test' => '0',
eileen's avatar
eileen committed
53
54
        'target_contact_name' => [],
        'assignee_contact_name' => [],
eileen's avatar
eileen committed
55
56
57
58
        'source_contact_id' => '3',
        'source_contact_name' => 'Anderson, Anthony',
        'checkbox' => 'mark_x_1',
        'mailingId' => '',
59
        'action' => '<span><a href="/index.php?q=civicrm/contact/view/contribution&amp;action=view&amp;reset=1&amp;id=1&amp;cid=3&amp;context=search&amp;searchContext=activity&amp;key=' . $qfKey . '" class="action-item crm-hover-button" title=\'View Activity\' >View</a></span>',
eileen's avatar
eileen committed
60
61
62
        'campaign' => NULL,
        'campaign_id' => NULL,
        'repeat' => '',
eileen's avatar
eileen committed
63
64
      ],
    ], $rows);
eileen's avatar
eileen committed
65
66
67
  }

}