--- /dev/null
+<?php
+/*
+ +--------------------------------------------------------------------+
+ | CiviCRM version 4.5 |
+ +--------------------------------------------------------------------+
+ | Copyright CiviCRM LLC (c) 2004-2014 |
+ +--------------------------------------------------------------------+
+ | This file is a part of CiviCRM. |
+ | |
+ | CiviCRM is free software; you can copy, modify, and distribute it |
+ | under the terms of the GNU Affero General Public License |
+ | Version 3, 19 November 2007 and the CiviCRM Licensing Exception. |
+ | |
+ | CiviCRM is distributed in the hope that it will be useful, but |
+ | WITHOUT ANY WARRANTY; without even the implied warranty of |
+ | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. |
+ | See the GNU Affero General Public License for more details. |
+ | |
+ | You should have received a copy of the GNU Affero General Public |
+ | License and the CiviCRM Licensing Exception along |
+ | with this program; if not, contact CiviCRM LLC |
+ | at info[AT]civicrm[DOT]org. If you have questions about the |
+ | GNU Affero General Public License or the licensing of CiviCRM, |
+ | see the CiviCRM license FAQ at http://civicrm.org/licensing |
+ +--------------------------------------------------------------------+
+*/
+
+require_once 'CiviTest/CiviUnitTestCase.php';
+
+/**
+ * Class CiviReportTestCase
+ */
+class CiviCaseTestCase extends CiviUnitTestCase {
+
+ protected $caseTypeId;
+ protected $caseStatusGroup;
+ protected $optionValues;
+ protected $_loggedInUser;
+
+ public function setUp() {
+ parent::setUp();
+ // CRM-9404 - set-up is a bit cumbersome but had to put something in place to set up activity types & case types
+ //. Using XML was causing breakage as id numbers were changing over time
+ // & was really hard to troubleshoot as involved truncating option_value table to mitigate this & not leaving DB in a
+ // state where tests could run afterwards without re-loading.
+ $this->caseStatusGroup = $this->callAPISuccess('option_group', 'get', array(
+ 'name' => 'case_status',
+ 'format.only_id' => 1
+ )
+ );
+ $optionValues = array(
+ 'Medical evaluation' => 'Medical evaluation',
+ 'Mental health evaluation' => "Mental health evaluation",
+ 'Secure temporary housing' => 'Secure temporary housing',
+ 'Long-term housing plan' => 'Long-term housing plan',
+ 'ADC referral' => 'ADC referral',
+ 'Income and benefits stabilization' => 'Income and benefits stabilization',
+ );
+ foreach ($optionValues as $name => $label) {
+ $activityTypes = $this->callAPISuccess('option_value', 'Create', array(
+ 'option_group_id' => 2,
+ 'name' => $name,
+ 'label' => $label,
+ 'component_id' => 7,
+ ));
+ // store for cleanup
+ $this->optionValues[] = $activityTypes['id'];
+ }
+ $this->caseTypeId = 1;
+ $this->tablesToTruncate = array(
+ 'civicrm_activity',
+ 'civicrm_contact',
+ 'civicrm_custom_group',
+ 'civicrm_custom_field',
+ 'civicrm_case',
+ 'civicrm_case_contact',
+ 'civicrm_case_activity',
+ 'civicrm_case_type',
+ 'civicrm_activity_contact',
+ 'civicrm_relationship',
+ 'civicrm_relationship_type',
+ );
+
+ $this->quickCleanup($this->tablesToTruncate);
+
+ $this->loadAllFixtures();
+
+ // enable the default custom templates for the case type xml files
+ $this->customDirectories(array('template_path' => TRUE));
+
+ // case is not enabled by default
+ $enableResult = CRM_Core_BAO_ConfigSetting::enableComponent('CiviCase');
+ $this->assertTrue($enableResult, 'Cannot enable CiviCase in line ' . __LINE__);
+
+ // create a logged in USER since the code references it for source_contact_id
+ $this->createLoggedInUser();
+ $session = CRM_Core_Session::singleton();
+ $this->_loggedInUser = $session->get('userID');
+ /// note that activityType options are cached by the FULL set of options you pass in
+ // ie. because Activity api includes campaign in it's call cache is not flushed unless
+ // included in this call. Also note flush function doesn't work on this property as it sets to null not empty array
+ CRM_Core_PseudoConstant::activityType(TRUE, TRUE, TRUE, 'name', TRUE);
+ }
+
+ /**
+ * Tears down the fixture, for example, closes a network connection.
+ * This method is called after a test is executed.
+ *
+ * @access protected
+ */
+ function tearDown() {
+ $this->quickCleanup($this->tablesToTruncate, TRUE);
+ $this->customDirectories(array('template_path' => FALSE));
+ }
+}
\ No newline at end of file
/**
* Include class definitions
*/
-require_once 'CiviTest/CiviUnitTestCase.php';
+require_once 'CiviTest/CiviCaseTestCase.php';
/**
* Test APIv3 civicrm_case_* functions
*
* @package CiviCRM_APIv3
*/
-class api_v3_CaseTest extends CiviUnitTestCase {
+class api_v3_CaseTest extends CiviCaseTestCase {
protected $_params;
protected $_entity;
protected $_apiversion =3;
protected $followup_activity_type_value;
- protected $caseTypeId;
- protected $caseStatusGroup;
- protected $optionValues;
/**
* Test setup for every test
$this->_entity = 'case';
parent::setUp();
- // CRM-9404 - set-up is a bit cumbersome but had to put something in place to set up activity types & case types
- //. Using XML was causing breakage as id numbers were changing over time
- // & was really hard to troubleshoot as involved truncating option_value table to mitigate this & not leaving DB in a
- // state where tests could run afterwards without re-loading.
- $this->caseStatusGroup = $this->callAPISuccess('option_group', 'get', array(
- 'name' => 'case_status',
- 'format.only_id' => 1)
- );
- $optionValues = array(
- 'Medical evaluation' => 'Medical evaluation',
- 'Mental health evaluation' => "Mental health evaluation",
- 'Secure temporary housing' => 'Secure temporary housing',
- 'Long-term housing plan' => 'Long-term housing plan',
- 'ADC referral' => 'ADC referral',
- 'Income and benefits stabilization' => 'Income and benefits stabilization',
- );
- foreach ($optionValues as $name => $label) {
- $activityTypes = $this->callAPISuccess('option_value', 'Create', array(
- 'option_group_id' => 2,
- 'name' => $name,
- 'label' => $label,
- 'component_id' => 7,
- ));
- // store for cleanup
- $this->optionValues[] = $activityTypes['id'];
- }
- $this->caseTypeId = 1;
- $this->tablesToTruncate = array(
- 'civicrm_activity',
- 'civicrm_contact',
- 'civicrm_custom_group',
- 'civicrm_custom_field',
- 'civicrm_case',
- 'civicrm_case_contact',
- 'civicrm_case_activity',
- 'civicrm_case_type',
- 'civicrm_activity_contact',
- 'civicrm_relationship',
- 'civicrm_relationship_type',
- );
-
- $this->quickCleanup($this->tablesToTruncate);
-
- $this->loadAllFixtures();
$activityTypes = $this->callAPISuccess('option_value', 'get', array(
'option_group_id' => 2,
));
$this->followup_activity_type_value = $activityTypes['values'][0]['value'];
- // enable the default custom templates for the case type xml files
- $this->customDirectories(array('template_path' => TRUE));
-
- // case is not enabled by default
- $enableResult = CRM_Core_BAO_ConfigSetting::enableComponent('CiviCase');
- $this->assertTrue($enableResult, 'Cannot enable CiviCase in line ' . __LINE__);
-
$this->_params = array(
'case_type_id' => $this->caseTypeId,
'subject' => 'Test case',
'contact_id' => 17,
);
-
- // create a logged in USER since the code references it for source_contact_id
- $this->createLoggedInUser();
- $session = CRM_Core_Session::singleton();
- $this->_loggedInUser = $session->get('userID');
- /// note that activityType options are cached by the FULL set of options you pass in
- // ie. because Activity api includes campaign in it's call cache is not flushed unless
- // included in this call. Also note flush function doesn't work on this property as it sets to null not empty array
- CRM_Core_PseudoConstant::activityType(TRUE, TRUE, TRUE, 'name', TRUE);
- }
-
- /**
- * Tears down the fixture, for example, closes a network connection.
- * This method is called after a test is executed.
- *
- * @access protected
- */
- function tearDown() {
- $this->quickCleanup($this->tablesToTruncate, TRUE);
-
- $this->customDirectories(array('template_path' => FALSE));
}
/**