4 +--------------------------------------------------------------------+
6 +--------------------------------------------------------------------+
7 | Copyright CiviCRM LLC (c) 2004-2020 |
8 +--------------------------------------------------------------------+
9 | This file is a part of CiviCRM. |
11 | CiviCRM is free software; you can copy, modify, and distribute it |
12 | under the terms of the GNU Affero General Public License |
13 | Version 3, 19 November 2007 and the CiviCRM Licensing Exception. |
15 | CiviCRM is distributed in the hope that it will be useful, but |
16 | WITHOUT ANY WARRANTY; without even the implied warranty of |
17 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. |
18 | See the GNU Affero General Public License for more details. |
20 | You should have received a copy of the GNU Affero General Public |
21 | License and the CiviCRM Licensing Exception along |
22 | with this program; if not, contact CiviCRM LLC |
23 | at info[AT]civicrm[DOT]org. If you have questions about the |
24 | GNU Affero General Public License or the licensing of CiviCRM, |
25 | see the CiviCRM license FAQ at http://civicrm.org/licensing |
26 +--------------------------------------------------------------------+
32 * @copyright CiviCRM LLC (c) 2004-2020
38 namespace api\v
4\Action
;
40 use Civi\Api4\Contact
;
41 use Civi\Api4\CustomField
;
42 use Civi\Api4\CustomGroup
;
43 use api\v
4\Traits\QueryCounterTrait
;
48 class CustomValuePerformanceTest
extends BaseCustomValueTest
{
50 use QueryCounterTrait
;
52 public function testQueryCount() {
54 $this->markTestIncomplete();
56 $customGroupId = CustomGroup
::create()
57 ->setCheckPermissions(FALSE)
58 ->addValue('name', 'MyContactFields')
59 ->addValue('title', 'MyContactFields')
60 ->addValue('extends', 'Contact')
65 ->setCheckPermissions(FALSE)
66 ->addValue('label', 'FavColor')
67 ->addValue('custom_group_id', $customGroupId)
68 ->addValue('options', ['r' => 'Red', 'g' => 'Green', 'b' => 'Blue'])
69 ->addValue('html_type', 'Select')
70 ->addValue('data_type', 'String')
74 ->setCheckPermissions(FALSE)
75 ->addValue('label', 'FavAnimal')
76 ->addValue('custom_group_id', $customGroupId)
77 ->addValue('html_type', 'Text')
78 ->addValue('data_type', 'String')
82 ->setCheckPermissions(FALSE)
83 ->addValue('label', 'FavLetter')
84 ->addValue('custom_group_id', $customGroupId)
85 ->addValue('html_type', 'Text')
86 ->addValue('data_type', 'String')
90 ->setCheckPermissions(FALSE)
91 ->addValue('label', 'FavFood')
92 ->addValue('custom_group_id', $customGroupId)
93 ->addValue('html_type', 'Text')
94 ->addValue('data_type', 'String')
97 $this->beginQueryCount();
100 ->setCheckPermissions(FALSE)
101 ->addValue('first_name', 'Red')
102 ->addValue('last_name', 'Tester')
103 ->addValue('contact_type', 'Individual')
104 ->addValue('MyContactFields.FavColor', 'r')
105 ->addValue('MyContactFields.FavAnimal', 'Sheep')
106 ->addValue('MyContactFields.FavLetter', 'z')
107 ->addValue('MyContactFields.FavFood', 'Coconuts')
111 ->setCheckPermissions(FALSE)
112 ->addSelect('display_name')
113 ->addSelect('MyContactFields.FavColor.label')
114 ->addSelect('MyContactFields.FavColor.weight')
115 ->addSelect('MyContactFields.FavColor.is_default')
116 ->addSelect('MyContactFields.FavAnimal')
117 ->addSelect('MyContactFields.FavLetter')
118 ->addWhere('MyContactFields.FavColor', '=', 'r')
119 ->addWhere('MyContactFields.FavFood', '=', 'Coconuts')
120 ->addWhere('MyContactFields.FavAnimal', '=', 'Sheep')
121 ->addWhere('MyContactFields.FavLetter', '=', 'z')
125 // FIXME: This count is artificially high due to the line
126 // $this->entity = Tables::getBriefName(Tables::getClassForTable($targetTable));
127 // In class Joinable. TODO: Investigate why.