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
20 namespace api\v
4\Action
;
22 use Civi\Api4\Contact
;
23 use Civi\Api4\CustomField
;
24 use Civi\Api4\CustomGroup
;
25 use api\v
4\Traits\QueryCounterTrait
;
30 class CustomValuePerformanceTest
extends BaseCustomValueTest
{
32 use QueryCounterTrait
;
34 public function testQueryCount() {
36 $this->markTestIncomplete();
38 $customGroupId = CustomGroup
::create(FALSE)
39 ->addValue('name', 'MyContactFields')
40 ->addValue('title', 'MyContactFields')
41 ->addValue('extends', 'Contact')
45 CustomField
::create(FALSE)
46 ->addValue('label', 'FavColor')
47 ->addValue('custom_group_id', $customGroupId)
48 ->addValue('options', ['r' => 'Red', 'g' => 'Green', 'b' => 'Blue'])
49 ->addValue('html_type', 'Select')
50 ->addValue('data_type', 'String')
53 CustomField
::create(FALSE)
54 ->addValue('label', 'FavAnimal')
55 ->addValue('custom_group_id', $customGroupId)
56 ->addValue('html_type', 'Text')
57 ->addValue('data_type', 'String')
60 CustomField
::create(FALSE)
61 ->addValue('label', 'FavLetter')
62 ->addValue('custom_group_id', $customGroupId)
63 ->addValue('html_type', 'Text')
64 ->addValue('data_type', 'String')
67 CustomField
::create(FALSE)
68 ->addValue('label', 'FavFood')
69 ->addValue('custom_group_id', $customGroupId)
70 ->addValue('html_type', 'Text')
71 ->addValue('data_type', 'String')
74 $this->beginQueryCount();
76 Contact
::create(FALSE)
77 ->addValue('first_name', 'Red')
78 ->addValue('last_name', 'Tester')
79 ->addValue('contact_type', 'Individual')
80 ->addValue('MyContactFields.FavColor', 'r')
81 ->addValue('MyContactFields.FavAnimal', 'Sheep')
82 ->addValue('MyContactFields.FavLetter', 'z')
83 ->addValue('MyContactFields.FavFood', 'Coconuts')
87 ->addSelect('display_name')
88 ->addSelect('MyContactFields.FavColor.label')
89 ->addSelect('MyContactFields.FavColor.weight')
90 ->addSelect('MyContactFields.FavColor.is_default')
91 ->addSelect('MyContactFields.FavAnimal')
92 ->addSelect('MyContactFields.FavLetter')
93 ->addWhere('MyContactFields.FavColor', '=', 'r')
94 ->addWhere('MyContactFields.FavFood', '=', 'Coconuts')
95 ->addWhere('MyContactFields.FavAnimal', '=', 'Sheep')
96 ->addWhere('MyContactFields.FavLetter', '=', 'z')
100 // FIXME: This count is artificially high due to the line
101 // $this->entity = Tables::getBriefName(Tables::getClassForTable($targetTable));
102 // In class Joinable. TODO: Investigate why.