QueryTest.php 1.71 KB
Newer Older
1
<?php
2

3 4
/**
 *  Include dataProvider for tests
5
 * @group headless
6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61
 */
class CRM_Case_BAO_QueryTest extends CiviUnitTestCase {

  /**
   * Set up function.
   *
   * Ensure CiviCase is enabled.
   */
  public function setUp() {
    parent::setUp();
    CRM_Core_BAO_ConfigSetting::enableComponent('CiviCase');
  }

  /**
   * Check that Qill is calculated correctly.
   *
   * CRM-17120 check the qill is still calculated after changing function used
   * to retrieve function.
   *
   * Note that the Qill doesn't actually appear to have the correct labels to
   * start with. I didn't attempt to fix that. I just prevented regression.
   *
   * I could not find anyway to actually do this search with the relevant fields
   * as parameters & don't know if they exist as legitimate code or code cruft so
   * this test was the only way I could verify the change.
   *  - case_recent_activity_type
   *  - case_activity_status_id
   *  - case_activity_medium_id
   */
  public function testWhereClauseSingle() {
    $params = array(
      0 => array(
        0 => 'case_recent_activity_type',
        1 => '=',
        2 => 6,
        3 => 1,
        4 => 0,
      ),
      1 => array(
        0 => 'case_activity_status_id',
        1 => '=',
        2 => 1,
        3 => 1,
        4 => 0,
      ),
      2 => array(
        0 => 'case_activity_medium_id',
        1 => '=',
        2 => 1,
        3 => 1,
        4 => 0,
      ),
    );

    $queryObj = new CRM_Contact_BAO_Query($params, NULL, NULL, FALSE, FALSE, CRM_Contact_BAO_Query::MODE_CASE);
    $this->assertEquals(array(
62 63 64
      0 => 'Activity Type = Contribution',
      1 => 'Activity Type = Scheduled',
      2 => 'Activity Medium = In Person',
65 66 67 68
    ),
    $queryObj->_qill[1]
    );
  }
69

70
}