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
22 namespace api\v
4\Action
;
24 use Civi\Api4\Contact
;
25 use Civi\Api4\CustomField
;
26 use Civi\Api4\CustomGroup
;
27 use CRM_Core_BAO_CustomValueTable
as CustomValueTable
;
32 class UpdateCustomValueTest
extends BaseCustomValueTest
{
34 public function testGetWithCustomData() {
36 $customGroup = CustomGroup
::create()
37 ->setCheckPermissions(FALSE)
38 ->addValue('name', 'MyContactFields')
39 ->addValue('extends', 'Contact')
44 ->setCheckPermissions(FALSE)
45 ->addValue('label', 'FavColor')
46 ->addValue('custom_group_id', $customGroup['id'])
47 ->addValue('html_type', 'Text')
48 ->addValue('data_type', 'String')
51 $contactId = Contact
::create()
52 ->setCheckPermissions(FALSE)
53 ->addValue('first_name', 'Red')
54 ->addValue('last_name', 'Tester')
55 ->addValue('contact_type', 'Individual')
56 ->addValue('MyContactFields.FavColor', 'Red')
61 ->setCheckPermissions(FALSE)
62 ->addWhere('id', '=', $contactId)
63 ->addValue('first_name', 'Red')
64 ->addValue('last_name', 'Tester')
65 ->addValue('contact_type', 'Individual')
66 ->addValue('MyContactFields.FavColor', 'Blue')
69 $result = CustomValueTable
::getEntityValues($contactId, 'Contact');
71 $this->assertEquals(1, count($result));
72 $this->assertContains('Blue', $result);