From a771c43fec8430c23837c0b6bb32c0283487524d Mon Sep 17 00:00:00 2001 From: kurund Date: Wed, 21 May 2014 18:58:45 +0530 Subject: [PATCH] added test to save xml file, CRM-14476 ---------------------------------------- * CRM-14476: Extend CaseType API to return/save XML https://issues.civicrm.org/jira/browse/CRM-14476 --- tests/phpunit/api/v3/CaseTypeTest.php | 34 +++++++- tests/phpunit/api/v3/dataset/sample_case.xml | 84 ++++++++++++++++++++ 2 files changed, 114 insertions(+), 4 deletions(-) create mode 100644 tests/phpunit/api/v3/dataset/sample_case.xml diff --git a/tests/phpunit/api/v3/CaseTypeTest.php b/tests/phpunit/api/v3/CaseTypeTest.php index 66c4566034..6a805a4f5a 100644 --- a/tests/phpunit/api/v3/CaseTypeTest.php +++ b/tests/phpunit/api/v3/CaseTypeTest.php @@ -76,10 +76,10 @@ class api_v3_CaseTypeTest extends CiviUnitTestCase { $this->callAPIFailure('CaseType', 'create', $params); } - /* - * test create methods with valid data - * success expected - */ + /** + * test create methods with valid data + * success expected + */ function testCaseTypeCreate() { // Create Case Type $params = array( @@ -144,5 +144,31 @@ class api_v3_CaseTypeTest extends CiviUnitTestCase { $result = $this->callAPISuccess('CaseType', 'get', array('id' => $id)); $this->assertEquals(0, $result['count']); } + + /** + * test create methods with xml file + * success expected + */ + function testCaseTypeCreateWithXML() { + $caseXMLFile = dirname(__FILE__) . '/dataset/sample_case.xml'; + + // Create Case Type + $params = array( + 'title' => 'Application with XML', + 'name' => 'Application_with_XML', + 'is_active' => 1, + 'weight' => 4, + 'xml_definition' => file_get_contents($caseXMLFile), + ); + + $result = $this->callAPISuccess('CaseType', 'create', $params); + $id = $result['id']; + + // Check result + $result = $this->callAPISuccess('CaseType', 'get', array('id' => $id)); + $this->assertEquals($result['values'][$id]['id'], $id, 'in line ' . __LINE__); + $this->assertEquals($result['values'][$id]['title'], $params['title'], 'in line ' . __LINE__); + $this->assertEquals($result['values'][$id]['xml_definition'], $params['xml_definition'], 'in line ' . __LINE__); + } } diff --git a/tests/phpunit/api/v3/dataset/sample_case.xml b/tests/phpunit/api/v3/dataset/sample_case.xml new file mode 100644 index 0000000000..d43daeae17 --- /dev/null +++ b/tests/phpunit/api/v3/dataset/sample_case.xml @@ -0,0 +1,84 @@ + + + + Adult Day Care Referral + + + Open Case + 1 + + + Medical evaluation + + + Mental health evaluation + + + ADC referral + + + Follow up + + + Change Case Type + + + Change Case Status + + + Change Case Start Date + + + Link Cases + + + + + standard_timeline + + true + + + Open Case + Completed + + + Medical evaluation + Open Case + 3 + newest + + + Mental health evaluation + Open Case + 7 + newest + + + ADC referral + Open Case + 10 + newest + + + Follow up + Open Case + 14 + newest + + + + + + + Senior Services Coordinator + 1 + + + Health Services Coordinator + + + Benefits Specialist + + + -- 2.25.1