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 api\v
4\Traits\QueryCounterTrait
;
32 class CustomValuePerformanceTest
extends BaseCustomValueTest
{
34 use QueryCounterTrait
;
36 public function testQueryCount() {
38 $this->markTestIncomplete();
40 $customGroupId = CustomGroup
::create()
41 ->setCheckPermissions(FALSE)
42 ->addValue('name', 'MyContactFields')
43 ->addValue('title', 'MyContactFields')
44 ->addValue('extends', 'Contact')
49 ->setCheckPermissions(FALSE)
50 ->addValue('label', 'FavColor')
51 ->addValue('custom_group_id', $customGroupId)
52 ->addValue('options', ['r' => 'Red', 'g' => 'Green', 'b' => 'Blue'])
53 ->addValue('html_type', 'Select')
54 ->addValue('data_type', 'String')
58 ->setCheckPermissions(FALSE)
59 ->addValue('label', 'FavAnimal')
60 ->addValue('custom_group_id', $customGroupId)
61 ->addValue('html_type', 'Text')
62 ->addValue('data_type', 'String')
66 ->setCheckPermissions(FALSE)
67 ->addValue('label', 'FavLetter')
68 ->addValue('custom_group_id', $customGroupId)
69 ->addValue('html_type', 'Text')
70 ->addValue('data_type', 'String')
74 ->setCheckPermissions(FALSE)
75 ->addValue('label', 'FavFood')
76 ->addValue('custom_group_id', $customGroupId)
77 ->addValue('html_type', 'Text')
78 ->addValue('data_type', 'String')
81 $this->beginQueryCount();
84 ->setCheckPermissions(FALSE)
85 ->addValue('first_name', 'Red')
86 ->addValue('last_name', 'Tester')
87 ->addValue('contact_type', 'Individual')
88 ->addValue('MyContactFields.FavColor', 'r')
89 ->addValue('MyContactFields.FavAnimal', 'Sheep')
90 ->addValue('MyContactFields.FavLetter', 'z')
91 ->addValue('MyContactFields.FavFood', 'Coconuts')
95 ->setCheckPermissions(FALSE)
96 ->addSelect('display_name')
97 ->addSelect('MyContactFields.FavColor.label')
98 ->addSelect('MyContactFields.FavColor.weight')
99 ->addSelect('MyContactFields.FavColor.is_default')
100 ->addSelect('MyContactFields.FavAnimal')
101 ->addSelect('MyContactFields.FavLetter')
102 ->addWhere('MyContactFields.FavColor', '=', 'r')
103 ->addWhere('MyContactFields.FavFood', '=', 'Coconuts')
104 ->addWhere('MyContactFields.FavAnimal', '=', 'Sheep')
105 ->addWhere('MyContactFields.FavLetter', '=', 'z')
109 // FIXME: This count is artificially high due to the line
110 // $this->entity = Tables::getBriefName(Tables::getClassForTable($targetTable));
111 // In class Joinable. TODO: Investigate why.