4 +--------------------------------------------------------------------+
5 | Copyright CiviCRM LLC. All rights reserved. |
7 | This work is published under the GNU AGPLv3 license with some |
8 | permitted exceptions and without any warranty. For full license |
9 | and copyright information, see https://civicrm.org/licensing |
10 +--------------------------------------------------------------------+
16 * @copyright CiviCRM LLC https://civicrm.org/licensing
20 namespace api\v
4\Action
;
22 use Civi\Api4\Contact
;
23 use Civi\Api4\CustomField
;
24 use Civi\Api4\CustomGroup
;
25 use CRM_Core_BAO_CustomValueTable
as CustomValueTable
;
30 class UpdateCustomValueTest
extends BaseCustomValueTest
{
32 public function testGetWithCustomData() {
34 $customGroup = CustomGroup
::create(FALSE)
35 ->addValue('name', 'MyContactFields')
36 ->addValue('extends', 'Contact')
40 CustomField
::create(FALSE)
41 ->addValue('label', 'FavColor')
42 ->addValue('custom_group_id', $customGroup['id'])
43 ->addValue('html_type', 'Text')
44 ->addValue('data_type', 'String')
47 $contactId = Contact
::create(FALSE)
48 ->addValue('first_name', 'Red')
49 ->addValue('last_name', 'Tester')
50 ->addValue('contact_type', 'Individual')
51 ->addValue('MyContactFields.FavColor', 'Red')
55 Contact
::update(FALSE)
56 ->addWhere('id', '=', $contactId)
57 ->addValue('first_name', 'Red')
58 ->addValue('last_name', 'Tester')
59 ->addValue('contact_type', 'Individual')
60 ->addValue('MyContactFields.FavColor', 'Blue')
63 $result = CustomValueTable
::getEntityValues($contactId, 'Contact');
65 $this->assertEquals(1, count($result));
66 $this->assertContains('Blue', $result);