fix header
[civicrm-core.git] / tests / phpunit / api / v3 / EventTest.php
index eb02eeb8b75adef21131e57d555d530ca36d0121..d456681a178580412eefaa9c7401eb6f9f0a1b3f 100644 (file)
@@ -3,7 +3,7 @@
  +--------------------------------------------------------------------+
  | CiviCRM version 4.7                                                |
  +--------------------------------------------------------------------+
- | Copyright CiviCRM LLC (c) 2004-2017                                |
+ | Copyright CiviCRM LLC (c) 2004-2018                                |
  +--------------------------------------------------------------------+
  | This file is a part of CiviCRM.                                    |
  |                                                                    |
@@ -409,6 +409,27 @@ class api_v3_EventTest extends CiviUnitTestCase {
     $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.
    *
@@ -752,7 +773,7 @@ class api_v3_EventTest extends CiviUnitTestCase {
       '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');