From 17f78bae9f86d5cf0f1316ac6d28288b7f53ee43 Mon Sep 17 00:00:00 2001 From: Coleman Watts Date: Fri, 24 Apr 2020 13:00:04 -0400 Subject: [PATCH] Correct option_group pseudoconstant and regenerate dao The option_group_id pseudoconstant was returning the `name` field as both "name" and "label" whereas the `title` field works better as "label". --- CRM/Case/DAO/Case.php | 6 +++--- CRM/Core/DAO/OptionValue.php | 5 +++-- tests/phpunit/CRM/Core/BAO/OptionGroupTest.php | 4 ++-- tests/phpunit/CRM/Core/PseudoConstantTest.php | 2 +- xml/schema/Core/OptionValue.xml | 3 ++- 5 files changed, 11 insertions(+), 9 deletions(-) diff --git a/CRM/Case/DAO/Case.php b/CRM/Case/DAO/Case.php index 9fa6b5aaf2..1b89c1a00c 100644 --- a/CRM/Case/DAO/Case.php +++ b/CRM/Case/DAO/Case.php @@ -6,7 +6,7 @@ * * Generated from xml/schema/CRM/Case/Case.xml * DO NOT EDIT. Generated by CRM_Core_CodeGen - * (GenCodeChecksum:0ff4c2d50e9ecac06f6bae975fb64aba) + * (GenCodeChecksum:02b3ed592b9c45f74b0d398c8cf25efd) */ /** @@ -64,7 +64,7 @@ class CRM_Case_DAO_Case extends CRM_Core_DAO { public $end_date; /** - * Details about the meeting (agenda, notes, etc). + * Details populated from Open Case. Only used in the CiviCase extension. * * @var text */ @@ -223,7 +223,7 @@ class CRM_Case_DAO_Case extends CRM_Core_DAO { 'name' => 'details', 'type' => CRM_Utils_Type::T_TEXT, 'title' => ts('Details'), - 'description' => ts('Details about the meeting (agenda, notes, etc).'), + 'description' => ts('Details populated from Open Case. Only used in the CiviCase extension.'), 'rows' => 8, 'cols' => 60, 'where' => 'civicrm_case.details', diff --git a/CRM/Core/DAO/OptionValue.php b/CRM/Core/DAO/OptionValue.php index a8dccef83a..fe2c9c4fc8 100644 --- a/CRM/Core/DAO/OptionValue.php +++ b/CRM/Core/DAO/OptionValue.php @@ -6,7 +6,7 @@ * * Generated from xml/schema/CRM/Core/OptionValue.xml * DO NOT EDIT. Generated by CRM_Core_CodeGen - * (GenCodeChecksum:b07a5bf40414e7b7c35fe49a1900df68) + * (GenCodeChecksum:c58b4d38fe97741293f8bc5ae5b64e98) */ /** @@ -215,7 +215,8 @@ class CRM_Core_DAO_OptionValue extends CRM_Core_DAO { 'pseudoconstant' => [ 'table' => 'civicrm_option_group', 'keyColumn' => 'id', - 'labelColumn' => 'name', + 'labelColumn' => 'title', + 'nameColumn' => 'name', ], ], 'label' => [ diff --git a/tests/phpunit/CRM/Core/BAO/OptionGroupTest.php b/tests/phpunit/CRM/Core/BAO/OptionGroupTest.php index 1672fa495e..ee2d706b81 100644 --- a/tests/phpunit/CRM/Core/BAO/OptionGroupTest.php +++ b/tests/phpunit/CRM/Core/BAO/OptionGroupTest.php @@ -39,11 +39,11 @@ class CRM_Core_BAO_OptionGroupTest extends CiviUnitTestCase { */ public function testEnsureOptionGroupExistsNewValue() { CRM_Core_BAO_OptionGroup::ensureOptionGroupExists(['name' => 'Bombed']); - $optionGroups = $this->callAPISuccess('OptionValue', 'getoptions', ['field' => 'option_group_id'])['values']; + $optionGroups = $this->callAPISuccess('OptionValue', 'getoptions', ['context' => 'validate', 'field' => 'option_group_id'])['values']; $this->assertTrue(in_array('bombed', $optionGroups)); CRM_Core_BAO_OptionGroup::ensureOptionGroupExists(['name' => 'Bombed Again']); - $optionGroups = $this->callAPISuccess('OptionValue', 'getoptions', ['field' => 'option_group_id'])['values']; + $optionGroups = $this->callAPISuccess('OptionValue', 'getoptions', ['context' => 'validate', 'field' => 'option_group_id'])['values']; $this->assertTrue(in_array('bombed_again', $optionGroups)); } diff --git a/tests/phpunit/CRM/Core/PseudoConstantTest.php b/tests/phpunit/CRM/Core/PseudoConstantTest.php index fda95feeea..ad76024aee 100644 --- a/tests/phpunit/CRM/Core/PseudoConstantTest.php +++ b/tests/phpunit/CRM/Core/PseudoConstantTest.php @@ -588,7 +588,7 @@ class CRM_Core_PseudoConstantTest extends CiviUnitTestCase { 'CRM_Core_DAO_OptionValue' => [ [ 'fieldName' => 'option_group_id', - 'sample' => 'gender', + 'sample' => 'Gender', 'max' => 200, ], [ diff --git a/xml/schema/Core/OptionValue.xml b/xml/schema/Core/OptionValue.xml index b86b1efd01..c8b7b3a2a4 100644 --- a/xml/schema/Core/OptionValue.xml +++ b/xml/schema/Core/OptionValue.xml @@ -28,7 +28,8 @@ civicrm_option_group
id - name + name + title
Select -- 2.25.1