+--------------------------------------------------------------------+
| CiviCRM version 4.7 |
+--------------------------------------------------------------------+
- | Copyright CiviCRM LLC (c) 2004-2017 |
+ | Copyright CiviCRM LLC (c) 2004-2018 |
+--------------------------------------------------------------------+
| This file is a part of CiviCRM. |
| |
$this->assertEquals($result['values'][$this->_eventIds[1]]['event_title'], 'Annual CiviCRM meet 2');
}
+ /**
+ * Test getLocationEvents() function invokes selectWhereClause() hook
+ */
+ public function testGetEventWithPermissionHook() {
+ $address = $this->callAPISuccess('address', 'create', array(
+ 'contact_id' => 'null',
+ 'location_type_id' => 1,
+ 'street_address' => '1234567',
+ ));
+ $params = array(
+ 'address_id' => $address['id'],
+ );
+ $result = $this->callAPISuccess('loc_block', 'create', $params);
+ $params = array(
+ 'id' => $this->_events[1]['id'],
+ 'loc_block_id' => $result['id'],
+ );
+ $this->callAPISuccess('Event', 'create', $params);
+ $result = CRM_Event_BAO_Event::getLocationEvents();
+ $this->assertEquals(1, count($result));
+
+ $this->hookClass->setHook('civicrm_selectWhereClause', array($this, 'selectWhereClauseHook'));
+ $result = CRM_Event_BAO_Event::getLocationEvents();
+ $this->assertEquals(0, count($result));
+ }
+
public function testGetEventByEventTitle() {
$params = array(
$this->customGroupDelete($ids['custom_group_id']);
}
+ /**
+ * Check searching on custom fields with IS NULL.
+ *
+ * https://issues.civicrm.org/jira/browse/CRM-20740
+ */
+ public function testSearchCustomFieldIsNull() {
+ // create custom group with custom field on event
+ $ids = $this->entityCustomGroupWithSingleFieldCreate(__FUNCTION__, __FILE__);
+
+ // Search for events having NULL as the value for this custom
+ // field. This should return all events created in setUp.
+ $check = $this->callAPISuccess($this->_entity, 'get', array(
+ 'custom_' . $ids['custom_field_id'] => array('IS NULL' => 1),
+ ));
+
+ $this->assertGreaterThan(0, $check['count']);
+
+ $this->customFieldDelete($ids['custom_field_id']);
+ $this->customGroupDelete($ids['custom_group_id']);
+ }
+
/**
* Test searching on custom fields returning a contact reference.
*
'title' => 'le cake is a tie',
'check_permissions' => TRUE,
);
- $config = &CRM_Core_Config::singleton();
+ $config = CRM_Core_Config::singleton();
$config->userPermissionClass->permissions = array('access CiviCRM');
$result = $this->callAPIFailure('event', 'create', $params);
$this->assertEquals('API permission check failed for Event/create call; insufficient permission: require access CiviCRM and access CiviEvent and edit all events', $result['error_message'], 'lacking permissions should not be enough to create an event');