Use new checkPermissions shorthand in api calls
[civicrm-core.git] / tests / phpunit / api / v4 / Action / CustomValuePerformanceTest.php
... / ...
CommitLineData
1<?php
2
3/*
4 +--------------------------------------------------------------------+
5 | Copyright CiviCRM LLC. All rights reserved. |
6 | |
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 +--------------------------------------------------------------------+
11 */
12
13/**
14 *
15 * @package CRM
16 * @copyright CiviCRM LLC https://civicrm.org/licensing
17 * $Id$
18 *
19 */
20
21
22namespace api\v4\Action;
23
24use Civi\Api4\Contact;
25use Civi\Api4\CustomField;
26use Civi\Api4\CustomGroup;
27use api\v4\Traits\QueryCounterTrait;
28
29/**
30 * @group headless
31 */
32class CustomValuePerformanceTest extends BaseCustomValueTest {
33
34 use QueryCounterTrait;
35
36 public function testQueryCount() {
37
38 $this->markTestIncomplete();
39
40 $customGroupId = CustomGroup::create(FALSE)
41 ->addValue('name', 'MyContactFields')
42 ->addValue('title', 'MyContactFields')
43 ->addValue('extends', 'Contact')
44 ->execute()
45 ->first()['id'];
46
47 CustomField::create(FALSE)
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
55 CustomField::create(FALSE)
56 ->addValue('label', 'FavAnimal')
57 ->addValue('custom_group_id', $customGroupId)
58 ->addValue('html_type', 'Text')
59 ->addValue('data_type', 'String')
60 ->execute();
61
62 CustomField::create(FALSE)
63 ->addValue('label', 'FavLetter')
64 ->addValue('custom_group_id', $customGroupId)
65 ->addValue('html_type', 'Text')
66 ->addValue('data_type', 'String')
67 ->execute();
68
69 CustomField::create(FALSE)
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
78 Contact::create(FALSE)
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
88 Contact::get(FALSE)
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}