From 466fba667f77b0cdcf0bdefc6cd42bd056b970de Mon Sep 17 00:00:00 2001 From: Tim Otten Date: Mon, 11 Aug 2014 23:29:34 -0700 Subject: [PATCH] CRM-15097 - CiviCase XML - Parse/encode property "forkable" --- CRM/Case/BAO/CaseType.php | 8 +++++++ tests/phpunit/CRM/Case/BAO/CaseTypeTest.php | 26 +++++++++++++++++++++ 2 files changed, 34 insertions(+) diff --git a/CRM/Case/BAO/CaseType.php b/CRM/Case/BAO/CaseType.php index 4b33515613..44e2169e96 100644 --- a/CRM/Case/BAO/CaseType.php +++ b/CRM/Case/BAO/CaseType.php @@ -99,6 +99,10 @@ class CRM_Case_BAO_CaseType extends CRM_Case_DAO_CaseType { $xmlFile = '' . "\n\n\n"; $xmlFile .= "{$name}\n"; + if (array_key_exists('forkable', $definition)) { + $xmlFile .= "" . ((int) $definition['forkable']) . "\n"; + } + if (isset($definition['activityTypes'])) { $xmlFile .= "\n"; foreach ($definition['activityTypes'] as $values) { @@ -175,6 +179,10 @@ class CRM_Case_BAO_CaseType extends CRM_Case_DAO_CaseType { // build PHP array based on definition $definition = array(); + if (isset($xml->forkable)) { + $definition['forkable'] = (int) $xml->forkable; + } + // set activity types if (isset($xml->ActivityTypes)) { $definition['activityTypes'] = array(); diff --git a/tests/phpunit/CRM/Case/BAO/CaseTypeTest.php b/tests/phpunit/CRM/Case/BAO/CaseTypeTest.php index aceffd4690..ebccffad52 100644 --- a/tests/phpunit/CRM/Case/BAO/CaseTypeTest.php +++ b/tests/phpunit/CRM/Case/BAO/CaseTypeTest.php @@ -182,12 +182,38 @@ class CRM_Case_BAO_CaseTypeTest extends CiviUnitTestCase { ', ); + $fixtures['forkable-0'] = array( + 'json' => json_encode(array( + 'forkable' => 0, + )), + 'xml' => ' + + Housing Support + 0 + + ', + ); + + $fixtures['forkable-1'] = array( + 'json' => json_encode(array( + 'forkable' => 1, + )), + 'xml' => ' + + Housing Support + 1 + + ', + ); + $cases = array(); foreach (array( 'empty-defn', 'empty-lists', 'one-item-in-each', 'two-items-in-each', + 'forkable-0', + 'forkable-1', ) as $key) { $cases[] = array($key, $fixtures[$key]['json'], $fixtures[$key]['xml']); } -- 2.25.1