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
;
31 class ExtendFromIndividualTest
extends BaseCustomValueTest
{
33 public function testGetWithNonStandardExtends() {
35 $customGroup = CustomGroup
::create(FALSE)
36 ->addValue('name', 'MyContactFields')
38 ->addValue('extends', 'Individual')
42 CustomField
::create(FALSE)
43 ->addValue('label', 'FavColor')
44 ->addValue('custom_group_id', $customGroup['id'])
45 ->addValue('html_type', 'Text')
46 ->addValue('data_type', 'String')
49 $contactId = Contact
::create(FALSE)
50 ->addValue('first_name', 'Johann')
51 ->addValue('last_name', 'Tester')
52 ->addValue('contact_type', 'Individual')
53 ->addValue('MyContactFields.FavColor', 'Red')
57 $contact = Contact
::get(FALSE)
58 ->addSelect('display_name')
59 ->addSelect('MyContactFields.FavColor')
60 ->addWhere('id', '=', $contactId)
64 $this->assertEquals('Red', $contact['MyContactFields.FavColor']);