Update Copywrite year to be 2019
[civicrm-core.git] / tests / phpunit / api / v3 / SyntaxConformanceTest.php
index fa0dbe649c78286ead06c42daedeb01daadaaaf2..ee607119d25072c4da553168f7d5b42828698568 100644 (file)
@@ -3,7 +3,7 @@
  +--------------------------------------------------------------------+
  | CiviCRM version 5                                                  |
  +--------------------------------------------------------------------+
- | Copyright CiviCRM LLC (c) 2004-2018                                |
+ | Copyright CiviCRM LLC (c) 2004-2019                                |
  +--------------------------------------------------------------------+
  | This file is a part of CiviCRM.                                    |
  |                                                                    |
@@ -838,6 +838,9 @@ class api_v3_SyntaxConformanceTest extends CiviUnitTestCase {
    * @param $entityName
    */
   public function testCustomDataGet($entityName) {
+    if ($entityName === 'Note') {
+      $this->markTestIncomplete('Note can not be processed here because of a vagary in the note api, it adds entity_table=contact to the get params when id is not present - which makes sense almost always but kills this test');
+    }
     $this->quickCleanup(array('civicrm_uf_match'));
     $this->createLoggedInUser();// so subsidiary activities are created
 
@@ -861,20 +864,35 @@ class api_v3_SyntaxConformanceTest extends CiviUnitTestCase {
     // We are not passing 'check_permissions' so the the more limited permissions *should* be
     // ignored but per CRM-17700 there is a history of custom data applying permissions when it shouldn't.
     CRM_Core_Config::singleton()->userPermissionClass->permissions = array('access CiviCRM', 'view my contact');
+    $objects = $this->getMockableBAOObjects($entityName, 1);
+
+    // simple custom field
     $ids = $this->entityCustomGroupWithSingleFieldCreate(__FUNCTION__, $usableName . 'Test.php');
     $customFieldName = 'custom_' . $ids['custom_field_id'];
-    $objects = $this->getMockableBAOObjects($entityName, 1);
     $params = array('id' => $objects[0]->id, 'custom_' . $ids['custom_field_id'] => "custom string");
     $result = $this->callAPISuccess($entityName, 'create', $params);
-
     $this->assertTrue(isset($result['id']), 'no id on ' . $entityName);
     $getParams = array('id' => $result['id'], 'return' => array($customFieldName));
     $check = $this->callAPISuccess($entityName, 'get', $getParams);
     $this->assertTrue(!empty($check['values'][$check['id']][$customFieldName]), 'Custom data not present for ' . $entityName);
     $this->assertEquals("custom string", $check['values'][$check['id']][$customFieldName], 'Custom data not present for ' . $entityName);
-
     $this->customFieldDelete($ids['custom_field_id']);
     $this->customGroupDelete($ids['custom_group_id']);
+
+    $ids2 = $this->entityCustomGroupWithSingleStringMultiSelectFieldCreate(__FUNCTION__, $usableName . 'Test.php');
+    $customFieldNameMultiSelect = 'custom_' . $ids2['custom_field_id'];
+    // String custom field, Multi-Select html type
+    foreach ($ids2['custom_field_group_options'] as $option_value => $option_label) {
+      $params = ['id' => $objects[0]->id, 'custom_' . $ids2['custom_field_id'] => $option_value];
+      $result = $this->callAPISuccess($entityName, 'create', $params);
+      $getParams = [$customFieldNameMultiSelect => $option_value, 'return' => [$customFieldNameMultiSelect]];
+      $this->callAPISuccessGetCount($entityName, $getParams, 1);
+    }
+
+    // cleanup
+    $this->customFieldDelete($ids2['custom_field_id']);
+    $this->customGroupDelete($ids2['custom_group_id']);
+
     $this->callAPISuccess($entityName, 'delete', array('id' => $result['id']));
     $this->quickCleanup(array('civicrm_uf_match'));
     if (!empty($createdValue)) {