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 | use api\v4\Traits\QueryCounterTrait; | |
28 | ||
29 | /** | |
30 | * @group headless | |
31 | */ | |
32 | class CustomValuePerformanceTest extends BaseCustomValueTest { | |
33 | ||
34 | use QueryCounterTrait; | |
35 | ||
36 | public function testQueryCount() { | |
37 | ||
38 | $this->markTestIncomplete(); | |
39 | ||
fe806431 | 40 | $customGroupId = CustomGroup::create(FALSE) |
19b53e5b C |
41 | ->addValue('name', 'MyContactFields') |
42 | ->addValue('title', 'MyContactFields') | |
43 | ->addValue('extends', 'Contact') | |
44 | ->execute() | |
45 | ->first()['id']; | |
46 | ||
fe806431 | 47 | CustomField::create(FALSE) |
19b53e5b C |
48 | ->addValue('label', 'FavColor') |
49 | ->addValue('custom_group_id', $customGroupId) | |
50 | ->addValue('options', ['r' => 'Red', 'g' => 'Green', 'b' => 'Blue']) | |
51 | ->addValue('html_type', 'Select') | |
52 | ->addValue('data_type', 'String') | |
53 | ->execute(); | |
54 | ||
fe806431 | 55 | CustomField::create(FALSE) |
19b53e5b C |
56 | ->addValue('label', 'FavAnimal') |
57 | ->addValue('custom_group_id', $customGroupId) | |
58 | ->addValue('html_type', 'Text') | |
59 | ->addValue('data_type', 'String') | |
60 | ->execute(); | |
61 | ||
fe806431 | 62 | CustomField::create(FALSE) |
19b53e5b C |
63 | ->addValue('label', 'FavLetter') |
64 | ->addValue('custom_group_id', $customGroupId) | |
65 | ->addValue('html_type', 'Text') | |
66 | ->addValue('data_type', 'String') | |
67 | ->execute(); | |
68 | ||
fe806431 | 69 | CustomField::create(FALSE) |
19b53e5b C |
70 | ->addValue('label', 'FavFood') |
71 | ->addValue('custom_group_id', $customGroupId) | |
72 | ->addValue('html_type', 'Text') | |
73 | ->addValue('data_type', 'String') | |
74 | ->execute(); | |
75 | ||
76 | $this->beginQueryCount(); | |
77 | ||
fe806431 | 78 | Contact::create(FALSE) |
19b53e5b C |
79 | ->addValue('first_name', 'Red') |
80 | ->addValue('last_name', 'Tester') | |
81 | ->addValue('contact_type', 'Individual') | |
82 | ->addValue('MyContactFields.FavColor', 'r') | |
83 | ->addValue('MyContactFields.FavAnimal', 'Sheep') | |
84 | ->addValue('MyContactFields.FavLetter', 'z') | |
85 | ->addValue('MyContactFields.FavFood', 'Coconuts') | |
86 | ->execute(); | |
87 | ||
fe806431 | 88 | Contact::get(FALSE) |
19b53e5b C |
89 | ->addSelect('display_name') |
90 | ->addSelect('MyContactFields.FavColor.label') | |
91 | ->addSelect('MyContactFields.FavColor.weight') | |
92 | ->addSelect('MyContactFields.FavColor.is_default') | |
93 | ->addSelect('MyContactFields.FavAnimal') | |
94 | ->addSelect('MyContactFields.FavLetter') | |
95 | ->addWhere('MyContactFields.FavColor', '=', 'r') | |
96 | ->addWhere('MyContactFields.FavFood', '=', 'Coconuts') | |
97 | ->addWhere('MyContactFields.FavAnimal', '=', 'Sheep') | |
98 | ->addWhere('MyContactFields.FavLetter', '=', 'z') | |
99 | ->execute() | |
100 | ->first(); | |
101 | ||
102 | // FIXME: This count is artificially high due to the line | |
103 | // $this->entity = Tables::getBriefName(Tables::getClassForTable($targetTable)); | |
104 | // In class Joinable. TODO: Investigate why. | |
105 | } | |
106 | ||
107 | } |