public static function basicTypeInfo($includeInactive = FALSE) {
$cacheKey = 'CRM_CT_BTI_' . (int) $includeInactive;
if (!Civi::cache('contactTypes')->has($cacheKey)) {
- $contactType = ContactType::get()->setCheckPermissions(FALSE)->setSelect(['*'])->addWhere('parent_id', 'IS NULL');
+ $contactType = ContactType::get(FALSE)->setSelect(['*'])->addWhere('parent_id', 'IS NULL');
if ($includeInactive === FALSE) {
$contactType->addWhere('is_active', '=', 1);
}
*/
protected static function getAllContactTypes() {
if (!Civi::cache('contactTypes')->has('all')) {
- $contactTypes = (array) ContactType::get()->setCheckPermissions(FALSE)
+ $contactTypes = (array) ContactType::get(FALSE)
->setSelect(['id', 'name', 'label', 'description', 'is_active', 'is_reserved', 'image_URL', 'parent_id', 'parent_id:name', 'parent_id:label'])
->execute()->indexBy('name');
* @throws \CiviCRM_API3_Exception
*/
public static function getSearchParams($id) {
- $savedSearch = \Civi\Api4\SavedSearch::get()
- ->setCheckPermissions(FALSE)
+ $savedSearch = \Civi\Api4\SavedSearch::get(FALSE)
->addWhere('id', '=', $id)
->execute()
->first();
'id' => $id,
]);
// First look for new-style template contribution with is_template=1
- $templateContributions = \Civi\Api4\Contribution::get()
- ->setCheckPermissions(FALSE)
+ $templateContributions = \Civi\Api4\Contribution::get(FALSE)
->addWhere('contribution_recur_id', '=', $id)
->addWhere('is_template', '=', 1)
->addWhere('is_test', '=', $is_test)
->execute();
if (!$templateContributions->count()) {
// Fall back to old style template contributions
- $templateContributions = \Civi\Api4\Contribution::get()
- ->setCheckPermissions(FALSE)
+ $templateContributions = \Civi\Api4\Contribution::get(FALSE)
->addWhere('contribution_recur_id', '=', $id)
->addWhere('is_test', '=', $is_test)
->addOrderBy('id', 'DESC')
throw new CRM_Core_Exception(ts("Message template's option value or ID missing."));
}
- $apiCall = MessageTemplate::get()
- ->setCheckPermissions(FALSE)
+ $apiCall = MessageTemplate::get(FALSE)
->addSelect('msg_subject', 'msg_text', 'msg_html', 'pdf_format_id', 'id')
->addWhere('is_default', '=', 1);
* @throws \Civi\API\Exception\UnauthorizedException
*/
protected static function filterRowBasedCustomDataFromCustomTables(array &$cidRefs) {
- $customTables = (array) CustomGroup::get()
- ->setCheckPermissions(FALSE)
+ $customTables = (array) CustomGroup::get(FALSE)
->setSelect(['table_name'])
->addWhere('is_multiple', '=', 0)
->addWhere('extends', 'IN', array_merge(['Contact'], CRM_Contact_BAO_ContactType::contactTypes()))
}
public static function populateMissingContactTypeName() {
- $contactTypes = \Civi\Api4\ContactType::get()
- ->setCheckPermissions(FALSE)
+ $contactTypes = \Civi\Api4\ContactType::get(FALSE)
->execute();
foreach ($contactTypes as $contactType) {
if (empty($contactType['name'])) {
if ($rev == '5.21.alpha1') {
// Find any option groups that were not converted during the upgrade.
$notConverted = [];
- $optionGroups = \Civi\Api4\OptionGroup::get()->setCheckPermissions(FALSE)->execute();
+ $optionGroups = \Civi\Api4\OptionGroup::get(FALSE)->execute();
foreach ($optionGroups as $optionGroup) {
$trimmedName = trim($optionGroup['name']);
if (strpos($trimmedName, ' ') !== FALSE) {
}
public static function fixOptionGroupName() {
- $optionGroups = \Civi\Api4\OptionGroup::get()
- ->setCheckPermissions(FALSE)
+ $optionGroups = \Civi\Api4\OptionGroup::get(FALSE)
->execute();
foreach ($optionGroups as $optionGroup) {
$name = trim($optionGroup['name']);
if (empty($this->checksConfig)) {
$this->checksConfig = Civi::cache('checks')->get('checksConfig', []);
if (empty($this->checksConfig)) {
- $this->checksConfig = StatusPreference::get()->setCheckPermissions(FALSE)->execute()->indexBy('name');
+ $this->checksConfig = StatusPreference::get(FALSE)->execute()->indexBy('name');
}
}
return $this->checksConfig;
}
foreach ($fields_indexed_by_group_id as $group_id => $fields) {
- \Civi\Api4\CustomField::save()
- ->setCheckPermissions(FALSE)
+ \Civi\Api4\CustomField::save(FALSE)
->setDefaults(['custom_group_id' => $group_id])
->setRecords(json_decode(json_encode($fields), TRUE))
->execute();
protected function findDomains() {
if ($this->domainId == 'all') {
- $this->domainId = Domain::get()->setCheckPermissions(FALSE)->addSelect('id')->execute()->column('id');
+ $this->domainId = Domain::get(FALSE)->addSelect('id')->execute()->column('id');
}
elseif ($this->domainId) {
$this->domainId = (array) $this->domainId;
- $domains = Domain::get()->setCheckPermissions(FALSE)->addSelect('id')->execute()->column('id');
+ $domains = Domain::get(FALSE)->addSelect('id')->execute()->column('id');
$invalid = array_diff($this->domainId, $domains);
if ($invalid) {
throw new \API_Exception('Invalid domain id: ' . implode(', ', $invalid));
$activityType = $request->getValue('activity_type');
if ($activityType) {
\CRM_Core_Error::deprecatedFunctionWarning('Use activity_type_id:name instead of activity_type in APIv4');
- $result = OptionValue::get()
- ->setCheckPermissions(FALSE)
+ $result = OptionValue::get(FALSE)
->addWhere('name', '=', $activityType)
->addWhere('option_group.name', '=', 'activity_type')
->execute();
return;
}
\CRM_Core_Error::deprecatedFunctionWarning('Use option_group_id:name instead of option_group in APIv4');
- $optionGroup = OptionGroup::get()
- ->setCheckPermissions(FALSE)
+ $optionGroup = OptionGroup::get(FALSE)
->addSelect('id')
->addWhere('name', '=', $optionGroupName)
->execute();
list($groupName, $fieldName) = explode('.', $name);
list($fieldName, $suffix) = array_pad(explode(':', $fieldName), 2, NULL);
if (empty(\Civi::$statics['APIv4_Custom_Fields'][$groupName])) {
- \Civi::$statics['APIv4_Custom_Fields'][$groupName] = (array) CustomField::get()
- ->setCheckPermissions(FALSE)
+ \Civi::$statics['APIv4_Custom_Fields'][$groupName] = (array) CustomField::get(FALSE)
->addSelect('id', 'name', 'html_type', 'custom_group.extends')
->addWhere('custom_group.name', '=', $groupName)
->execute()->indexBy('name');
*/
public function getEntityFields() {
if (!$this->entityFields) {
- $fields = CustomField::get()
- ->setCheckPermissions(FALSE)
+ $fields = CustomField::get(FALSE)
->setSelect(['custom_group.name', 'custom_group.extends', 'custom_group.table_name', '*'])
->addWhere('custom_group.table_name', '=', $this->getTargetTable())
->execute();
*/
public function __construct(EventDispatcherInterface $dispatcher) {
$this->dispatcher = $dispatcher;
- $this->apiEntities = array_keys((array) Entity::get()->setCheckPermissions(FALSE)->addSelect('name')->execute()->indexBy('name'));
+ $this->apiEntities = array_keys((array) Entity::get(FALSE)->addSelect('name')->execute()->indexBy('name'));
}
/**
if ($entity === 'Participant') {
$extends = ['Participant', 'ParticipantRole', 'ParticipantEventName', 'ParticipantEventType'];
}
- $customFields = CustomField::get()
- ->setCheckPermissions(FALSE)
+ $customFields = CustomField::get(FALSE)
->addWhere('custom_group.extends', 'IN', $extends)
->addWhere('custom_group.is_multiple', '=', '0')
->setSelect(['custom_group.name', '*'])
* @param \Civi\Api4\Service\Spec\RequestSpec $specification
*/
private function getCustomGroupFields($customGroup, RequestSpec $specification) {
- $customFields = CustomField::get()
- ->setCheckPermissions(FALSE)
+ $customFields = CustomField::get(FALSE)
->addWhere('custom_group.name', '=', $customGroup)
->setSelect(['custom_group.name', 'custom_group.table_name', '*'])
->execute();
* Add menu item when enabled.
*/
public function enable() {
- \Civi\Api4\Navigation::create()
- ->setCheckPermissions(FALSE)
+ \Civi\Api4\Navigation::create(FALSE)
->addValue('parent_id:name', 'Search')
->addValue('label', E::ts('Create Search...'))
->addValue('name', 'create_search')
* Delete menu item when disabled.
*/
public function disable() {
- \Civi\Api4\Navigation::delete()
- ->setCheckPermissions(FALSE)
+ \Civi\Api4\Navigation::delete(FALSE)
->addWhere('name', '=', 'create_search')
->addWhere('domain_id', '=', 'current_domain')
->execute();
$reversalStatuses = ['Cancelled', 'Chargeback', 'Refunded'];
if (empty($params['creditnote_id']) && in_array(CRM_Core_PseudoConstant::getName('CRM_Contribute_BAO_Contribution', 'contribution_status_id', $params['contribution_status_id']), $reversalStatuses, TRUE)) {
if ($id) {
- $existing = Contribution::get()->setCheckPermissions(FALSE)->addWhere('id', '=', (int) $id)->setSelect(['creditnote_id'])->execute()->first();
+ $existing = Contribution::get(FALSE)->addWhere('id', '=', (int) $id)->setSelect(['creditnote_id'])->execute()->first();
if ($existing['creditnote_id']) {
// Since we have it adding it makes is clearer.
$params['creditnote_id'] = $existing['creditnote_id'];
'This is a test Signature',
]);
$mut->stop();
- $activity = Activity::get()->setCheckPermissions(FALSE)->setSelect(['details'])->execute()->first();
+ $activity = Activity::get(FALSE)->setSelect(['details'])->execute()->first();
$bccUrl1 = CRM_Utils_System::url('civicrm/contact/view', ['reset' => 1, 'force' => 1, 'cid' => $bcc1], TRUE);
$bccUrl2 = CRM_Utils_System::url('civicrm/contact/view', ['reset' => 1, 'force' => 1, 'cid' => $bcc2], TRUE);
$this->assertContains("bcc : <a href='" . $bccUrl1 . "'>Mr. Anthony Anderson II</a><a href='" . $bccUrl2 . "'>Mr. Anthony Anderson II</a>", $activity['details']);
));
$activity->save();
- ActivityContact::create()->setCheckPermissions(FALSE)->setValues([
+ ActivityContact::create(FALSE)->setValues([
'contact_id' => $contact['id'],
'activity_id' => $activity->id,
'record_type_id:name' => 'Activity Source',
);
$this->assertInternalType('numeric', $membership->id);
if ($emailParams) {
- Civi\Api4\Email::create()->setCheckPermissions(FALSE)->setValues(array_merge([
+ Civi\Api4\Email::create(FALSE)->setValues(array_merge([
'contact_id' => $membership->contact_id,
'location_type_id' => 1,
], $emailParams))->execute();
'max_multiple' => 0,
], $params);
$identifier = $params['name'] ?? $params['title'];
- $this->ids['CustomGroup'][$identifier] = CustomGroup::create()->setCheckPermissions(FALSE)->setValues($params)->execute()->first()['id'];
+ $this->ids['CustomGroup'][$identifier] = CustomGroup::create(FALSE)->setValues($params)->execute()->first()['id'];
return $this->ids['CustomGroup'][$identifier];
}
$group = uniqid('mg');
$textField = uniqid('tx');
- CustomGroup::create()
- ->setCheckPermissions(FALSE)
+ CustomGroup::create(FALSE)
->addValue('name', $group)
->addValue('extends', 'Contact')
->addValue('is_multiple', TRUE)
public function testWithSingleField() {
- $customGroup = CustomGroup::create()
- ->setCheckPermissions(FALSE)
+ $customGroup = CustomGroup::create(FALSE)
->addValue('name', 'MyIndividualFields')
->addValue('extends', 'Individual')
->execute()
->first();
- CustomField::create()
- ->setCheckPermissions(FALSE)
+ CustomField::create(FALSE)
->addValue('label', 'FavColor')
->addValue('custom_group_id', $customGroup['id'])
->addValue('html_type', 'Text')
->execute();
// Individual fields should show up when contact_type = null|Individual but not other contact types
- $getFields = Contact::getFields()->setCheckPermissions(FALSE);
+ $getFields = Contact::getFields(FALSE);
$this->assertContains('MyIndividualFields.FavColor', $getFields->execute()->column('name'));
$this->assertContains('MyIndividualFields.FavColor', $getFields->setValues(['contact_type' => 'Individual'])->execute()->column('name'));
$this->assertNotContains('MyIndividualFields.FavColor', $getFields->setValues(['contact_type' => 'Household'])->execute()->column('name'));
- $contactId = Contact::create()
- ->setCheckPermissions(FALSE)
+ $contactId = Contact::create(FALSE)
->addValue('first_name', 'Johann')
->addValue('last_name', 'Tester')
->addValue('contact_type', 'Individual')
->execute()
->first()['id'];
- $contact = Contact::get()
- ->setCheckPermissions(FALSE)
+ $contact = Contact::get(FALSE)
->addSelect('first_name')
->addSelect('MyIndividualFields.FavColor')
->addWhere('id', '=', $contactId)
->addValue('MyIndividualFields.FavColor', 'Blue')
->execute();
- $contact = Contact::get()
- ->setCheckPermissions(FALSE)
+ $contact = Contact::get(FALSE)
->addSelect('MyIndividualFields.FavColor')
->addWhere('id', '=', $contactId)
->execute()
public function testWithTwoFields() {
// First custom set
- CustomGroup::create()
- ->setCheckPermissions(FALSE)
+ CustomGroup::create(FALSE)
->addValue('name', 'MyContactFields')
->addValue('extends', 'Contact')
->addChain('field1', CustomField::create()
->execute();
// Second custom set
- CustomGroup::create()
- ->setCheckPermissions(FALSE)
+ CustomGroup::create(FALSE)
->addValue('name', 'MyContactFields2')
->addValue('extends', 'Contact')
->addChain('field1', CustomField::create()
->addValue('data_type', 'String'))
->execute();
- $contactId1 = Contact::create()
- ->setCheckPermissions(FALSE)
+ $contactId1 = Contact::create(FALSE)
->addValue('first_name', 'Johann')
->addValue('last_name', 'Tester')
->addValue('MyContactFields.FavColor', 'Red')
->execute()
->first()['id'];
- $contactId2 = Contact::create()
- ->setCheckPermissions(FALSE)
+ $contactId2 = Contact::create(FALSE)
->addValue('first_name', 'MaryLou')
->addValue('last_name', 'Tester')
->addValue('MyContactFields.FavColor', 'Purple')
->execute()
->first()['id'];
- $contact = Contact::get()
- ->setCheckPermissions(FALSE)
+ $contact = Contact::get(FALSE)
->addSelect('first_name')
->addSelect('MyContactFields.FavColor')
->addSelect('MyContactFields.FavFood')
->addValue('MyContactFields2.FavColor', 'Orange')
->addValue('MyContactFields2.FavFood', 'Tangerine')
->execute();
- $contact = Contact::get()
- ->setCheckPermissions(FALSE)
+ $contact = Contact::get(FALSE)
->addSelect('MyContactFields.FavColor', 'MyContactFields2.FavColor', 'MyContactFields.FavFood', 'MyContactFields2.FavFood')
->addWhere('id', '=', $contactId1)
->execute()
->addWhere('id', '=', $contactId1)
->addValue('MyContactFields.FavColor', 'Blue')
->execute();
- $contact = Contact::get()
- ->setCheckPermissions(FALSE)
+ $contact = Contact::get(FALSE)
->addSelect('MyContactFields.FavColor', 'MyContactFields2.FavColor', 'MyContactFields.FavFood', 'MyContactFields2.FavFood')
->addWhere('id', '=', $contactId1)
->execute()
$this->assertEquals('Cherry', $contact['MyContactFields.FavFood']);
$this->assertEquals('Tangerine', $contact['MyContactFields2.FavFood']);
- $search = Contact::get()
- ->setCheckPermissions(FALSE)
+ $search = Contact::get(FALSE)
->addClause('OR', ['MyContactFields.FavColor', '=', 'Blue'], ['MyContactFields.FavFood', '=', 'Grapes'])
->addSelect('id')
->addOrderBy('id')
$this->assertEquals([$contactId1, $contactId2], array_keys((array) $search));
- $search = Contact::get()
- ->setCheckPermissions(FALSE)
+ $search = Contact::get(FALSE)
->addClause('NOT', ['MyContactFields.FavColor', '=', 'Purple'], ['MyContactFields.FavFood', '=', 'Grapes'])
->addSelect('id')
->addOrderBy('id')
$this->assertNotContains($contactId2, array_keys((array) $search));
- $search = Contact::get()
- ->setCheckPermissions(FALSE)
+ $search = Contact::get(FALSE)
->addClause('NOT', ['MyContactFields.FavColor', '=', 'Purple'], ['MyContactFields.FavFood', '=', 'Grapes'])
->addSelect('id')
->addOrderBy('id')
$this->assertContains($contactId1, array_keys((array) $search));
$this->assertNotContains($contactId2, array_keys((array) $search));
- $search = Contact::get()
- ->setCheckPermissions(FALSE)
+ $search = Contact::get(FALSE)
->setWhere([['NOT', ['OR', [['MyContactFields.FavColor', '=', 'Blue'], ['MyContactFields.FavFood', '=', 'Grapes']]]]])
->addSelect('id')
->addOrderBy('id')
* Expects at least one activity loaded from the data set.
*/
public function testGetAllHousingSupportActivities() {
- $results = Activity::get()
- ->setCheckPermissions(FALSE)
+ $results = Activity::get(FALSE)
->addWhere('activity_type_id:name', '=', 'Phone Call')
->execute();
class ContactChecksumTest extends \api\v4\UnitTestCase {
public function testGetChecksum() {
- $contact = Contact::create()
- ->setCheckPermissions(FALSE)
+ $contact = Contact::create(FALSE)
->addValue('first_name', 'Check')
->addValue('last_name', 'Sum')
->addChain('cs', Contact::getChecksum()->setContactId('$id')->setTtl(500), 0)
}
public function testValidateChecksum() {
- $cid = Contact::create()
- ->setCheckPermissions(FALSE)
+ $cid = Contact::create(FALSE)
->addValue('first_name', 'Checker')
->addValue('last_name', 'Sum')
->execute()
->setValues(['first_name' => 'Dan', 'last_name' => $last_name])
->execute()->first();
- $num = Contact::get()->setCheckPermissions(FALSE)->selectRowCount()->execute()->count();
+ $num = Contact::get(FALSE)->selectRowCount()->execute()->count();
// The object's count() method will account for all results, ignoring limit & offset, while the array results are limited
- $offset1 = Contact::get()->setCheckPermissions(FALSE)->setOffset(1)->execute();
+ $offset1 = Contact::get(FALSE)->setOffset(1)->execute();
$this->assertCount($num, $offset1);
$this->assertCount($num - 1, (array) $offset1);
- $offset2 = Contact::get()->setCheckPermissions(FALSE)->setOffset(2)->execute();
+ $offset2 = Contact::get(FALSE)->setOffset(2)->execute();
$this->assertCount($num - 2, (array) $offset2);
$this->assertCount($num, $offset2);
// With limit, it doesn't fetch total count by default
- $limit2 = Contact::get()->setCheckPermissions(FALSE)->setLimit(2)->execute();
+ $limit2 = Contact::get(FALSE)->setLimit(2)->execute();
$this->assertCount(2, (array) $limit2);
$this->assertCount(2, $limit2);
// With limit, you have to trigger the full row count manually
- $limit2 = Contact::get()->setCheckPermissions(FALSE)->setLimit(2)->addSelect('sort_name', 'row_count')->execute();
+ $limit2 = Contact::get(FALSE)->setLimit(2)->addSelect('sort_name', 'row_count')->execute();
$this->assertCount(2, (array) $limit2);
$this->assertCount($num, $limit2);
}
public function testGetWithCustomData() {
$optionValues = ['r' => 'Red', 'g' => 'Green', 'b' => 'Blue'];
- $customGroup = CustomGroup::create()
- ->setCheckPermissions(FALSE)
+ $customGroup = CustomGroup::create(FALSE)
->addValue('name', 'MyContactFields')
->addValue('extends', 'Contact')
->execute()
->first();
- CustomField::create()
- ->setCheckPermissions(FALSE)
+ CustomField::create(FALSE)
->addValue('label', 'Color')
->addValue('option_values', $optionValues)
->addValue('custom_group_id', $customGroup['id'])
->addValue('data_type', 'String')
->execute();
- $customField = CustomField::get()
- ->setCheckPermissions(FALSE)
+ $customField = CustomField::get(FALSE)
->addWhere('label', '=', 'Color')
->execute()
->first();
$this->assertNotNull($customField['option_group_id']);
$optionGroupId = $customField['option_group_id'];
- $optionGroup = OptionGroup::get()
- ->setCheckPermissions(FALSE)
+ $optionGroup = OptionGroup::get(FALSE)
->addWhere('id', '=', $optionGroupId)
->execute()
->first();
$this->assertEquals('Color', $optionGroup['title']);
- $createdOptionValues = OptionValue::get()
- ->setCheckPermissions(FALSE)
+ $createdOptionValues = OptionValue::get(FALSE)
->addWhere('option_group_id', '=', $optionGroupId)
->execute()
->getArrayCopy();
$colorField = uniqid('colora');
$foodField = uniqid('fooda');
- $customGroupId = CustomGroup::create()
- ->setCheckPermissions(FALSE)
+ $customGroupId = CustomGroup::create(FALSE)
->addValue('name', $group)
->addValue('extends', 'Contact')
->execute()
->first()['id'];
- CustomField::create()
- ->setCheckPermissions(FALSE)
+ CustomField::create(FALSE)
->addValue('label', $colorField)
->addValue('name', $colorField)
->addValue('option_values', ['r' => 'Red', 'g' => 'Green', 'b' => 'Blue'])
->addValue('data_type', 'String')
->execute();
- CustomField::create()
- ->setCheckPermissions(FALSE)
+ CustomField::create(FALSE)
->addValue('label', $foodField)
->addValue('name', $foodField)
->addValue('option_values', ['1' => 'Corn', '2' => 'Potatoes', '3' => 'Cheese'])
->addValue('data_type', 'String')
->execute();
- $customGroupId = CustomGroup::create()
- ->setCheckPermissions(FALSE)
+ $customGroupId = CustomGroup::create(FALSE)
->addValue('name', 'FinancialStuff')
->addValue('extends', 'Contact')
->execute()
->first()['id'];
- CustomField::create()
- ->setCheckPermissions(FALSE)
+ CustomField::create(FALSE)
->addValue('label', 'Salary')
->addValue('custom_group_id', $customGroupId)
->addValue('html_type', 'Number')
->addValue('data_type', 'Money')
->execute();
- Contact::create()
- ->setCheckPermissions(FALSE)
+ Contact::create(FALSE)
->addValue('first_name', 'Jerome')
->addValue('last_name', 'Tester')
->addValue('contact_type', 'Individual')
->addValue('FinancialStuff.Salary', 50000)
->execute();
- $result = Contact::get()
- ->setCheckPermissions(FALSE)
+ $result = Contact::get(FALSE)
->addSelect('first_name')
->addSelect("$group.$colorField:label")
->addSelect("$group.$foodField:label")
$colorField = uniqid('colorb');
$foodField = uniqid('foodb');
- $customGroupId = CustomGroup::create()
- ->setCheckPermissions(FALSE)
+ $customGroupId = CustomGroup::create(FALSE)
->addValue('name', $group)
->addValue('extends', 'Contact')
->execute()
->first()['id'];
- CustomField::create()
- ->setCheckPermissions(FALSE)
+ CustomField::create(FALSE)
->addValue('label', $colorField)
->addValue('name', $colorField)
->addValue('option_values', ['r' => 'Red', 'g' => 'Green', 'b' => 'Blue'])
->addValue('data_type', 'String')
->execute();
- CustomField::create()
- ->setCheckPermissions(FALSE)
+ CustomField::create(FALSE)
->addValue('label', $foodField)
->addValue('name', $foodField)
->addValue('option_values', ['1' => 'Corn', '2' => 'Potatoes', '3' => 'Cheese'])
->addValue('data_type', 'String')
->execute();
- $customGroupId = CustomGroup::create()
- ->setCheckPermissions(FALSE)
+ $customGroupId = CustomGroup::create(FALSE)
->addValue('name', 'FinancialStuff')
->addValue('extends', 'Contact')
->execute()
->first()['id'];
- CustomField::create()
- ->setCheckPermissions(FALSE)
+ CustomField::create(FALSE)
->addValue('label', 'Salary')
->addValue('custom_group_id', $customGroupId)
->addValue('html_type', 'Number')
->addValue('data_type', 'Money')
->execute();
- Contact::create()
- ->setCheckPermissions(FALSE)
+ Contact::create(FALSE)
->addValue('first_name', 'Red')
->addValue('last_name', 'Corn')
->addValue('contact_type', 'Individual')
->addValue('FinancialStuff.Salary', 10000)
->execute();
- Contact::create()
- ->setCheckPermissions(FALSE)
+ Contact::create(FALSE)
->addValue('first_name', 'Blue')
->addValue('last_name', 'Cheese')
->addValue('contact_type', 'Individual')
->addValue('FinancialStuff.Salary', 500000)
->execute();
- $result = Contact::get()
- ->setCheckPermissions(FALSE)
+ $result = Contact::get(FALSE)
->addSelect('first_name')
->addSelect('last_name')
->addSelect("$group.$colorField:label")
$this->markTestIncomplete();
- $customGroupId = CustomGroup::create()
- ->setCheckPermissions(FALSE)
+ $customGroupId = CustomGroup::create(FALSE)
->addValue('name', 'MyContactFields')
->addValue('title', 'MyContactFields')
->addValue('extends', 'Contact')
->execute()
->first()['id'];
- CustomField::create()
- ->setCheckPermissions(FALSE)
+ CustomField::create(FALSE)
->addValue('label', 'FavColor')
->addValue('custom_group_id', $customGroupId)
->addValue('options', ['r' => 'Red', 'g' => 'Green', 'b' => 'Blue'])
->addValue('data_type', 'String')
->execute();
- CustomField::create()
- ->setCheckPermissions(FALSE)
+ CustomField::create(FALSE)
->addValue('label', 'FavAnimal')
->addValue('custom_group_id', $customGroupId)
->addValue('html_type', 'Text')
->addValue('data_type', 'String')
->execute();
- CustomField::create()
- ->setCheckPermissions(FALSE)
+ CustomField::create(FALSE)
->addValue('label', 'FavLetter')
->addValue('custom_group_id', $customGroupId)
->addValue('html_type', 'Text')
->addValue('data_type', 'String')
->execute();
- CustomField::create()
- ->setCheckPermissions(FALSE)
+ CustomField::create(FALSE)
->addValue('label', 'FavFood')
->addValue('custom_group_id', $customGroupId)
->addValue('html_type', 'Text')
$this->beginQueryCount();
- Contact::create()
- ->setCheckPermissions(FALSE)
+ Contact::create(FALSE)
->addValue('first_name', 'Red')
->addValue('last_name', 'Tester')
->addValue('contact_type', 'Individual')
->addValue('MyContactFields.FavFood', 'Coconuts')
->execute();
- Contact::get()
- ->setCheckPermissions(FALSE)
+ Contact::get(FALSE)
->addSelect('display_name')
->addSelect('MyContactFields.FavColor.label')
->addSelect('MyContactFields.FavColor.weight')
$multiField = uniqid('chkbx');
$textField = uniqid('txt');
- $customGroup = CustomGroup::create()
- ->setCheckPermissions(FALSE)
+ $customGroup = CustomGroup::create(FALSE)
->addValue('name', $group)
->addValue('extends', 'Contact')
->addValue('is_multiple', TRUE)
->execute()
->first();
- CustomField::create()
- ->setCheckPermissions(FALSE)
+ CustomField::create(FALSE)
->addValue('label', $colorField)
->addValue('option_values', $optionValues)
->addValue('custom_group_id', $customGroup['id'])
->addValue('data_type', 'String')
->execute();
- CustomField::create()
- ->setCheckPermissions(FALSE)
+ CustomField::create(FALSE)
->addValue('label', $multiField)
->addValue('option_values', $optionValues)
->addValue('custom_group_id', $customGroup['id'])
->addValue('data_type', 'String')
->execute();
- CustomField::create()
- ->setCheckPermissions(FALSE)
+ CustomField::create(FALSE)
->addValue('label', $textField)
->addValue('custom_group_id', $customGroup['id'])
->addValue('html_type', 'Text')
->addValue('data_type', 'String')
->execute();
- $this->contactID = Contact::create()
- ->setCheckPermissions(FALSE)
+ $this->contactID = Contact::create(FALSE)
->addValue('first_name', 'Johann')
->addValue('last_name', 'Tester')
->addValue('contact_type', 'Individual')
// CASE 3: Test CustomValue::replace
// create a second contact which will be used to replace the custom values, created earlier
- $secondContactID = Contact::create()
- ->setCheckPermissions(FALSE)
+ $secondContactID = Contact::create(FALSE)
->addValue('first_name', 'Adam')
->addValue('last_name', 'Tester')
->addValue('contact_type', 'Individual')
public function testGetWithNonStandardExtends() {
- $customGroup = CustomGroup::create()
- ->setCheckPermissions(FALSE)
+ $customGroup = CustomGroup::create(FALSE)
->addValue('name', 'MyContactFields')
// not Contact
->addValue('extends', 'Individual')
->execute()
->first();
- CustomField::create()
- ->setCheckPermissions(FALSE)
+ CustomField::create(FALSE)
->addValue('label', 'FavColor')
->addValue('custom_group_id', $customGroup['id'])
->addValue('html_type', 'Text')
->addValue('data_type', 'String')
->execute();
- $contactId = Contact::create()
- ->setCheckPermissions(FALSE)
+ $contactId = Contact::create(FALSE)
->addValue('first_name', 'Johann')
->addValue('last_name', 'Tester')
->addValue('contact_type', 'Individual')
->execute()
->first()['id'];
- $contact = Contact::get()
- ->setCheckPermissions(FALSE)
+ $contact = Contact::get(FALSE)
->addSelect('display_name')
->addSelect('MyContactFields.FavColor')
->addWhere('id', '=', $contactId)
* loaded from the data set.
*/
public function testThreeLevelJoin() {
- $results = Activity::get()
- ->setCheckPermissions(FALSE)
+ $results = Activity::get(FALSE)
->addWhere('activity_type_id:name', '=', 'Phone Call')
->execute();
public function testOptionalJoin() {
// DefaultDataSet includes 2 phones for contact 1, 0 for contact 2.
// We'll add one for contact 2 as a red herring to make sure we only get back the correct ones.
- Phone::create()->setCheckPermissions(FALSE)
+ Phone::create(FALSE)
->setValues(['contact_id' => $this->getReference('test_contact_2')['id'], 'phone' => '123456'])
->execute();
- $contacts = Contact::get()
- ->setCheckPermissions(FALSE)
+ $contacts = Contact::get(FALSE)
->addJoin('Phone', FALSE)
->addSelect('id', 'phone.phone')
->addWhere('id', 'IN', [$this->getReference('test_contact_1')['id']])
public function testRequiredJoin() {
// Joining with no condition
- $contacts = Contact::get()
- ->setCheckPermissions(FALSE)
+ $contacts = Contact::get(FALSE)
->addSelect('id', 'phone.phone')
->addJoin('Phone', TRUE)
->addWhere('id', 'IN', [$this->getReference('test_contact_1')['id'], $this->getReference('test_contact_2')['id']])
$this->assertEquals($this->getReference('test_contact_1')['id'], $contacts[1]['id']);
// Add is_primary condition, should result in only one record
- $contacts = Contact::get()
- ->setCheckPermissions(FALSE)
+ $contacts = Contact::get(FALSE)
->addSelect('id', 'phone.phone', 'phone.location_type_id')
->addJoin('Phone', TRUE, ['phone.is_primary', '=', TRUE])
->addWhere('id', 'IN', [$this->getReference('test_contact_1')['id'], $this->getReference('test_contact_2')['id']])
}
public function testJoinToTheSameTableTwice() {
- $cid1 = Contact::create()->setCheckPermissions(FALSE)
+ $cid1 = Contact::create(FALSE)
->addValue('first_name', 'Aaa')
->addChain('email1', Email::create()->setValues(['email' => 'yoohoo@yahoo.test', 'contact_id' => '$id', 'location_type_id:name' => 'Home']))
->addChain('email2', Email::create()->setValues(['email' => 'yahoo@yoohoo.test', 'contact_id' => '$id', 'location_type_id:name' => 'Work']))
->execute()
->first()['id'];
- $cid2 = Contact::create()->setCheckPermissions(FALSE)
+ $cid2 = Contact::create(FALSE)
->addValue('first_name', 'Bbb')
->addChain('email1', Email::create()->setValues(['email' => '1@test.test', 'contact_id' => '$id', 'location_type_id:name' => 'Home']))
->addChain('email2', Email::create()->setValues(['email' => '2@test.test', 'contact_id' => '$id', 'location_type_id:name' => 'Work']))
->execute()
->first()['id'];
- $cid3 = Contact::create()->setCheckPermissions(FALSE)
+ $cid3 = Contact::create(FALSE)
->addValue('first_name', 'Ccc')
->execute()
->first()['id'];
- $contacts = Contact::get()
- ->setCheckPermissions(FALSE)
+ $contacts = Contact::get(FALSE)
->addSelect('id', 'first_name', 'any_email.email', 'any_email.location_type_id:name', 'any_email.is_primary', 'primary_email.email')
->addJoin('Email AS any_email', TRUE)
->addJoin('Email AS primary_email', FALSE, ['primary_email.is_primary', '=', TRUE])
class GetExtraFieldsTest extends UnitTestCase {
public function testGetFieldsByContactType() {
- $getFields = Contact::getFields()->setCheckPermissions(FALSE)->addSelect('name')->setIncludeCustom(FALSE);
+ $getFields = Contact::getFields(FALSE)->addSelect('name')->setIncludeCustom(FALSE);
$baseFields = array_column(\CRM_Contact_BAO_Contact::fields(), 'name');
$returnedFields = $getFields->execute()->column('name');
}
public function testGetOptionsAddress() {
- $getFields = Address::getFields()->setCheckPermissions(FALSE)->addWhere('name', '=', 'state_province_id')->setLoadOptions(TRUE);
+ $getFields = Address::getFields(FALSE)->addWhere('name', '=', 'state_province_id')->setLoadOptions(TRUE);
$usOptions = $getFields->setValues(['country_id' => 1228])->execute()->first();
}
public function testStringNull() {
- $contact = Contact::create()
- ->setCheckPermissions(FALSE)
+ $contact = Contact::create(FALSE)
->addValue('first_name', 'Joseph')
->addValue('last_name', 'null')
->addValue('contact_type', 'Individual')
}
public function testSettingToNull() {
- $contact = Contact::create()
- ->setCheckPermissions(FALSE)
+ $contact = Contact::create(FALSE)
->addValue('first_name', 'ILoveMy')
->addValue('last_name', 'LastName')
->addValue('contact_type', 'Individual')
$this->assertSame('ILoveMy LastName', $contact['display_name']);
$contactId = $contact['id'];
- $contact = Contact::update()
- ->setCheckPermissions(FALSE)
+ $contact = Contact::update(FALSE)
->addWhere('id', '=', $contactId)
->addValue('last_name', NULL)
->execute()
}
public function testSaveWithReload() {
- $contact = Contact::create()
- ->setCheckPermissions(FALSE)
+ $contact = Contact::create(FALSE)
->addValue('first_name', 'Firsty')
->addValue('last_name', 'Lasty')
->execute()
->first();
- $activity = Activity::create()
- ->setCheckPermissions(FALSE)
+ $activity = Activity::create(FALSE)
->addValue('source_contact_id', $contact['id'])
->addValue('activity_type_id', 1)
->addValue('subject', 'hello')
$this->assertEquals('hello', $activity['subject']);
- $saved = Activity::save()
- ->setCheckPermissions(FALSE)
+ $saved = Activity::save(FALSE)
->addRecord(['id' => $activity['id'], 'subject' => NULL])
->execute()
->first();
$this->assertNull($saved['subject']);
$this->assertArrayNotHasKey('activity_date_time', $saved);
- $saved = Activity::save()
- ->setCheckPermissions(FALSE)
+ $saved = Activity::save(FALSE)
->addRecord(['id' => $activity['id'], 'subject' => NULL])
->setReload(TRUE)
->execute()
class PseudoconstantTest extends BaseCustomValueTest {
public function testOptionValue() {
- $cid = Contact::create()->setCheckPermissions(FALSE)->addValue('first_name', 'bill')->execute()->first()['id'];
+ $cid = Contact::create(FALSE)->addValue('first_name', 'bill')->execute()->first()['id'];
$subject = uniqid('subject');
OptionValue::create()
->addValue('option_group_id:name', 'activity_type')
}
public function testAddressOptions() {
- $cid = Contact::create()->setCheckPermissions(FALSE)->addValue('first_name', 'addr')->execute()->first()['id'];
+ $cid = Contact::create(FALSE)->addValue('first_name', 'addr')->execute()->first()['id'];
Address::save()
->addRecord([
'contact_id' => $cid,
['id' => 'b', 'name' => 'blue', 'label' => 'BLUE', 'color' => '#0000ff', 'description' => 'Blue color', 'icon' => 'fa-blue'],
];
- CustomGroup::create()
- ->setCheckPermissions(FALSE)
+ CustomGroup::create(FALSE)
->addValue('name', 'myPseudoconstantTest')
->addValue('extends', 'Individual')
->addChain('field1', CustomField::create()
}
}
- $cid = Contact::create()
- ->setCheckPermissions(FALSE)
+ $cid = Contact::create(FALSE)
->addValue('first_name', 'col')
->addValue('myPseudoconstantTest.Color:label', 'blü')
->execute()->first()['id'];
- $result = Contact::get()
- ->setCheckPermissions(FALSE)
+ $result = Contact::get(FALSE)
->addWhere('id', '=', $cid)
->addSelect('myPseudoconstantTest.Color:name', 'myPseudoconstantTest.Color:label', 'myPseudoconstantTest.Color')
->execute()->first();
$this->assertEquals('bl_', $result['myPseudoconstantTest.Color:name']);
$this->assertEquals('b', $result['myPseudoconstantTest.Color']);
- $cid1 = Contact::create()
- ->setCheckPermissions(FALSE)
+ $cid1 = Contact::create(FALSE)
->addValue('first_name', 'two')
->addValue('myPseudoconstantTest.Technicolor:label', 'RED')
->execute()->first()['id'];
- $cid2 = Contact::create()
- ->setCheckPermissions(FALSE)
+ $cid2 = Contact::create(FALSE)
->addValue('first_name', 'two')
->addValue('myPseudoconstantTest.Technicolor:label', 'GREEN')
->execute()->first()['id'];
// Test ordering by label
- $result = Contact::get()
- ->setCheckPermissions(FALSE)
+ $result = Contact::get(FALSE)
->addWhere('id', 'IN', [$cid1, $cid2])
->addSelect('id')
->addOrderBy('myPseudoconstantTest.Technicolor:label')
->execute()->first()['id'];
$this->assertEquals($cid2, $result);
- $result = Contact::get()
- ->setCheckPermissions(FALSE)
+ $result = Contact::get(FALSE)
->addWhere('id', 'IN', [$cid1, $cid2])
->addSelect('id')
->addOrderBy('myPseudoconstantTest.Technicolor:label', 'DESC')
}
public function testJoinOptions() {
- $cid1 = Contact::create()->setCheckPermissions(FALSE)
+ $cid1 = Contact::create(FALSE)
->addValue('first_name', 'Tom')
->addValue('gender_id:label', 'Male')
->addChain('email', Email::create()->setValues(['contact_id' => '$id', 'email' => 'tom@example.com', 'location_type_id:name' => 'Work']))
->execute()->first()['id'];
- $cid2 = Contact::create()->setCheckPermissions(FALSE)
+ $cid2 = Contact::create(FALSE)
->addValue('first_name', 'Sue')
->addValue('gender_id:name', 'Female')
->addChain('email', Email::create()->setValues(['contact_id' => '$id', 'email' => 'sue@example.com', 'location_type_id:name' => 'Home']))
->execute()->first()['id'];
- $cid3 = Contact::create()->setCheckPermissions(FALSE)
+ $cid3 = Contact::create(FALSE)
->addValue('first_name', 'Pat')
->addChain('email', Email::create()->setValues(['contact_id' => '$id', 'email' => 'pat@example.com', 'location_type_id:name' => 'Home']))
->execute()->first()['id'];
public function testTagOptions() {
$tag = uniqid('tag');
- Tag::create()->setCheckPermissions(FALSE)
+ Tag::create(FALSE)
->addValue('name', $tag)
->addValue('description', 'colorful')
->addValue('color', '#aabbcc')
}
public function testCustomValueReplace() {
- $customGroup = CustomGroup::create()
- ->setCheckPermissions(FALSE)
+ $customGroup = CustomGroup::create(FALSE)
->addValue('name', 'replaceTest')
->addValue('extends', 'Contact')
->addValue('is_multiple', TRUE)
->addValue('data_type', 'String')
->execute();
- CustomField::create()
- ->setCheckPermissions(FALSE)
+ CustomField::create(FALSE)
->addValue('label', 'Custom2')
->addValue('custom_group_id', $customGroup['id'])
->addValue('html_type', 'String')
class ResultTest extends UnitTestCase {
public function testJsonSerialize() {
- $result = Contact::getFields()->setCheckPermissions(FALSE)->setIncludeCustom(FALSE)->execute();
+ $result = Contact::getFields(FALSE)->setIncludeCustom(FALSE)->execute();
$json = json_encode($result);
$this->assertStringStartsWith('[{"', $json);
$this->assertTrue(is_array(json_decode($json)));
}
public function testGroupAggregates() {
- $cid = Contact::create()->setCheckPermissions(FALSE)->addValue('first_name', 'bill')->execute()->first()['id'];
- Contribution::save()
- ->setCheckPermissions(FALSE)
+ $cid = Contact::create(FALSE)->addValue('first_name', 'bill')->execute()->first()['id'];
+ Contribution::save(FALSE)
->setDefaults(['contact_id' => $cid, 'financial_type_id' => 1])
->setRecords([
['total_amount' => 100, 'receive_date' => '2020-01-01'],
['total_amount' => 400, 'receive_date' => '2020-01-01'],
])
->execute();
- $agg = Contribution::get()
- ->setCheckPermissions(FALSE)
+ $agg = Contribution::get(FALSE)
->addGroupBy('contact_id')
->addWhere('contact_id', '=', $cid)
->addSelect('AVG(total_amount) AS average')
}
public function testGroupHaving() {
- $cid = Contact::create()->setCheckPermissions(FALSE)->addValue('first_name', 'donor')->execute()->first()['id'];
- Contribution::save()
- ->setCheckPermissions(FALSE)
+ $cid = Contact::create(FALSE)->addValue('first_name', 'donor')->execute()->first()['id'];
+ Contribution::save(FALSE)
->setDefaults(['contact_id' => $cid, 'financial_type_id' => 1])
->setRecords([
['total_amount' => 100, 'receive_date' => '2020-02-02'],
['total_amount' => 400, 'receive_date' => '2020-04-04'],
])
->execute();
- $result = Contribution::get()
- ->setCheckPermissions(FALSE)
+ $result = Contribution::get(FALSE)
->addGroupBy('contact_id')
->addGroupBy('receive_date')
->addSelect('contact_id')
class UpdateContactTest extends UnitTestCase {
public function testUpdateWithIdInWhere() {
- $contactId = Contact::create()
- ->setCheckPermissions(FALSE)
+ $contactId = Contact::create(FALSE)
->addValue('first_name', 'Johann')
->addValue('last_name', 'Tester')
->addValue('contact_type', 'Individual')
->execute()
->first()['id'];
- $contact = Contact::update()
- ->setCheckPermissions(FALSE)
+ $contact = Contact::update(FALSE)
->addWhere('id', '=', $contactId)
->addValue('first_name', 'Testy')
->execute()
}
public function testUpdateWithIdInValues() {
- $contactId = Contact::create()
- ->setCheckPermissions(FALSE)
+ $contactId = Contact::create(FALSE)
->addValue('first_name', 'Bobby')
->addValue('last_name', 'Tester')
->addValue('contact_type', 'Individual')
->execute()
->first()['id'];
- $contact = Contact::update()
- ->setCheckPermissions(FALSE)
+ $contact = Contact::update(FALSE)
->addValue('id', $contactId)
->addValue('first_name', 'Billy')
->execute();
public function testGetWithCustomData() {
- $customGroup = CustomGroup::create()
- ->setCheckPermissions(FALSE)
+ $customGroup = CustomGroup::create(FALSE)
->addValue('name', 'MyContactFields')
->addValue('extends', 'Contact')
->execute()
->first();
- CustomField::create()
- ->setCheckPermissions(FALSE)
+ CustomField::create(FALSE)
->addValue('label', 'FavColor')
->addValue('custom_group_id', $customGroup['id'])
->addValue('html_type', 'Text')
->addValue('data_type', 'String')
->execute();
- $contactId = Contact::create()
- ->setCheckPermissions(FALSE)
+ $contactId = Contact::create(FALSE)
->addValue('first_name', 'Red')
->addValue('last_name', 'Tester')
->addValue('contact_type', 'Individual')
->execute()
->first()['id'];
- Contact::update()
- ->setCheckPermissions(FALSE)
+ Contact::update(FALSE)
->addWhere('id', '=', $contactId)
->addValue('first_name', 'Red')
->addValue('last_name', 'Tester')
* @throws \Civi\API\Exception\UnauthorizedException
*/
public function getEntitiesHitech() {
- return $this->toDataProviderArray(Entity::get()->setCheckPermissions(FALSE)->execute()->column('name'));
+ return $this->toDataProviderArray(Entity::get(FALSE)->execute()->column('name'));
}
/**
* @param string $entity
*/
protected function checkFields($entityClass, $entity) {
- $fields = $entityClass::getFields()
- ->setCheckPermissions(FALSE)
+ $fields = $entityClass::getFields(FALSE)
->setIncludeCustom(FALSE)
->execute()
->indexBy('name');
* @return array
*/
protected function checkActions($entityClass) {
- $actions = $entityClass::getActions()
- ->setCheckPermissions(FALSE)
+ $actions = $entityClass::getActions(FALSE)
->execute()
->indexBy('name');
protected function checkUpdateFailsFromCreate($entityClass, $id) {
$exceptionThrown = '';
try {
- $entityClass::create()
- ->setCheckPermissions(FALSE)
+ $entityClass::create(FALSE)
->addValue('id', $id)
->execute();
}
* @param string $entity
*/
protected function checkGet($entityClass, $id, $entity) {
- $getResult = $entityClass::get()
- ->setCheckPermissions(FALSE)
+ $getResult = $entityClass::get(FALSE)
->addWhere('id', '=', $id)
->execute();
* @param string $entity
*/
protected function checkGetCount($entityClass, $id, $entity) {
- $getResult = $entityClass::get()
- ->setCheckPermissions(FALSE)
+ $getResult = $entityClass::get(FALSE)
->addWhere('id', '=', $id)
->selectRowCount()
->execute();
$errMsg = sprintf('%s getCount failed', $entity);
$this->assertEquals(1, $getResult->count(), $errMsg);
- $getResult = $entityClass::get()
- ->setCheckPermissions(FALSE)
+ $getResult = $entityClass::get(FALSE)
->selectRowCount()
->execute();
$errMsg = sprintf('%s getCount failed', $entity);
* @param int $id
*/
protected function checkDeletion($entityClass, $id) {
- $deleteResult = $entityClass::delete()
- ->setCheckPermissions(FALSE)
+ $deleteResult = $entityClass::delete(FALSE)
->addWhere('id', '=', $id)
->execute();
* @param string $entity
*/
protected function checkPostDelete($entityClass, $id, $entity) {
- $getDeletedResult = $entityClass::get()
- ->setCheckPermissions(FALSE)
+ $getDeletedResult = $entityClass::get(FALSE)
->addWhere('id', '=', $id)
->execute();
->setCheckPermissions(FALSE)
->execute()->first()['id'];
- $result = Contact::get()
- ->setCheckPermissions(FALSE)
+ $result = Contact::get(FALSE)
->addSelect('*', 'prefix_id:label')
->addWhere('id', 'IN', [$indiv, $org, $hh])
->execute()
$this->assertArrayNotHasKey('household_name', $result[$org]);
$this->assertArrayNotHasKey('household_name', $result[$indiv]);
- $emails = Email::get()
- ->setCheckPermissions(FALSE)
+ $emails = Email::get(FALSE)
->addWhere('contact_id', 'IN', [$indiv, $org, $hh])
->addSelect('id', 'contact_id', 'contact.*', 'contact.prefix_id:label')
->execute()
class EntityTest extends UnitTestCase {
public function testEntityGet() {
- $result = Entity::get()
- ->setCheckPermissions(FALSE)
+ $result = Entity::get(FALSE)
->execute()
->indexBy('name');
$this->assertArrayHasKey('Entity', $result,
}
public function testEntity() {
- $result = Entity::getActions()
- ->setCheckPermissions(FALSE)
+ $result = Entity::getActions(FALSE)
->execute()
->indexBy('name');
$this->assertNotContains(
}
public function testGetActions() {
- $result = Participant::getActions()
- ->setCheckPermissions(FALSE)
+ $result = Participant::getActions(FALSE)
->execute()
->indexBy('name');
}
// With no records:
- $result = Participant::get()->setCheckPermissions(FALSE)->execute();
+ $result = Participant::get(FALSE)->execute();
$this->assertEquals(0, $result->count(), "count of empty get is not 0");
// Check that the $result knows what the inputs were
$secondEventId = $dummy['events'][1]['id'];
$firstContactId = $dummy['contacts'][0]['id'];
- $firstOnlyResult = Participant::get()
- ->setCheckPermissions(FALSE)
+ $firstOnlyResult = Participant::get(FALSE)
->addClause('AND', ['event_id', '=', $firstEventId])
->execute();
"count of first event is not $expectedFirstEventCount");
// get first two events using different methods
- $firstTwo = Participant::get()
- ->setCheckPermissions(FALSE)
+ $firstTwo = Participant::get(FALSE)
->addWhere('event_id', 'IN', [$firstEventId, $secondEventId])
->execute();
"count is too low"
);
- $firstParticipantResult = Participant::get()
- ->setCheckPermissions(FALSE)
+ $firstParticipantResult = Participant::get(FALSE)
->addWhere('event_id', '=', $firstEventId)
->addWhere('contact_id', '=', $firstContactId)
->execute();
$firstParticipantId = $firstParticipantResult->first()['id'];
// get a result which excludes $first_participant
- $otherParticipantResult = Participant::get()
- ->setCheckPermissions(FALSE)
+ $otherParticipantResult = Participant::get(FALSE)
->setSelect(['id'])
->addClause('NOT', [
['event_id', '=', $firstEventId],
->indexBy('id');
// check alternate syntax for NOT
- $otherParticipantResult2 = Participant::get()
- ->setCheckPermissions(FALSE)
+ $otherParticipantResult2 = Participant::get(FALSE)
->setSelect(['id'])
->addClause('NOT', 'AND', [
['event_id', '=', $firstEventId],
class SavedSearchTest extends UnitTestCase {
public function testContactSmartGroup() {
- $in = Contact::create()->setCheckPermissions(FALSE)->addValue('first_name', 'yes')->addValue('do_not_phone', TRUE)->execute()->first();
- $out = Contact::create()->setCheckPermissions(FALSE)->addValue('first_name', 'no')->addValue('do_not_phone', FALSE)->execute()->first();
+ $in = Contact::create(FALSE)->addValue('first_name', 'yes')->addValue('do_not_phone', TRUE)->execute()->first();
+ $out = Contact::create(FALSE)->addValue('first_name', 'no')->addValue('do_not_phone', FALSE)->execute()->first();
$savedSearch = civicrm_api4('SavedSearch', 'create', [
'values' => [
}
public function testEmailSmartGroup() {
- $in = Contact::create()->setCheckPermissions(FALSE)->addValue('first_name', 'yep')->execute()->first();
- $out = Contact::create()->setCheckPermissions(FALSE)->addValue('first_name', 'nope')->execute()->first();
+ $in = Contact::create(FALSE)->addValue('first_name', 'yep')->execute()->first();
+ $out = Contact::create(FALSE)->addValue('first_name', 'nope')->execute()->first();
$email = uniqid() . '@' . uniqid();
- Email::create()->setCheckPermissions(FALSE)->addValue('email', $email)->addValue('contact_id', $in['id'])->execute();
+ Email::create(FALSE)->addValue('email', $email)->addValue('contact_id', $in['id'])->execute();
$savedSearch = civicrm_api4('SavedSearch', 'create', [
'values' => [
}
public function testPseudoConstantOptionsWillBeAdded() {
- $customGroupId = CustomGroup::create()
- ->setCheckPermissions(FALSE)
+ $customGroupId = CustomGroup::create(FALSE)
->addValue('name', 'FavoriteThings')
->addValue('extends', 'Contact')
->execute()
$options = ['r' => 'Red', 'g' => 'Green', 'p' => 'Pink'];
- CustomField::create()
- ->setCheckPermissions(FALSE)
+ CustomField::create(FALSE)
->addValue('label', 'FavColor')
->addValue('custom_group_id', $customGroupId)
->addValue('option_values', $options)