Commit | Line | Data |
---|---|---|
19b53e5b C |
1 | <?php |
2 | ||
380f3545 TO |
3 | /* |
4 | +--------------------------------------------------------------------+ | |
7d61e75f | 5 | | Copyright CiviCRM LLC. All rights reserved. | |
380f3545 | 6 | | | |
7d61e75f TO |
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 | | |
380f3545 TO |
10 | +--------------------------------------------------------------------+ |
11 | */ | |
12 | ||
13 | /** | |
14 | * | |
15 | * @package CRM | |
ca5cec67 | 16 | * @copyright CiviCRM LLC https://civicrm.org/licensing |
380f3545 TO |
17 | * $Id$ |
18 | * | |
19 | */ | |
20 | ||
21 | ||
19b53e5b C |
22 | namespace api\v4\Action; |
23 | ||
24 | use Civi\Api4\Contact; | |
25 | use Civi\Api4\CustomField; | |
26 | use Civi\Api4\CustomGroup; | |
27 | ||
28 | /** | |
29 | * @group headless | |
30 | */ | |
31 | class ExtendFromIndividualTest extends BaseCustomValueTest { | |
32 | ||
33 | public function testGetWithNonStandardExtends() { | |
34 | ||
35 | $customGroup = CustomGroup::create() | |
36 | ->setCheckPermissions(FALSE) | |
37 | ->addValue('name', 'MyContactFields') | |
38 | // not Contact | |
39 | ->addValue('extends', 'Individual') | |
40 | ->execute() | |
41 | ->first(); | |
42 | ||
43 | CustomField::create() | |
44 | ->setCheckPermissions(FALSE) | |
45 | ->addValue('label', 'FavColor') | |
46 | ->addValue('custom_group_id', $customGroup['id']) | |
47 | ->addValue('html_type', 'Text') | |
48 | ->addValue('data_type', 'String') | |
49 | ->execute(); | |
50 | ||
51 | $contactId = Contact::create() | |
52 | ->setCheckPermissions(FALSE) | |
53 | ->addValue('first_name', 'Johann') | |
54 | ->addValue('last_name', 'Tester') | |
55 | ->addValue('contact_type', 'Individual') | |
56 | ->addValue('MyContactFields.FavColor', 'Red') | |
57 | ->execute() | |
58 | ->first()['id']; | |
59 | ||
60 | $contact = Contact::get() | |
61 | ->setCheckPermissions(FALSE) | |
62 | ->addSelect('display_name') | |
63 | ->addSelect('MyContactFields.FavColor') | |
64 | ->addWhere('id', '=', $contactId) | |
65 | ->execute() | |
66 | ->first(); | |
67 | ||
68 | $this->assertEquals('Red', $contact['MyContactFields.FavColor']); | |
69 | } | |
70 | ||
71 | } |