Merge pull request #11838 from mfb/ses-smtp-support
[civicrm-core.git] / tests / phpunit / api / v3 / CustomFieldTest.php
index 51c49c8409687be60ce3c9da95154eb500cb1fa4..95076fc7a33826317a5e8d8882b9ee97ea228521 100644 (file)
@@ -1,7 +1,7 @@
 <?php
 /*
  +--------------------------------------------------------------------+
-| CiviCRM version 4.7                                                |
+| CiviCRM version 5                                                  |
 +--------------------------------------------------------------------+
 | Copyright CiviCRM LLC (c) 2004-2018                                |
 +--------------------------------------------------------------------+
@@ -544,6 +544,31 @@ class api_v3_CustomFieldTest extends CiviUnitTestCase {
     $this->assertEquals($attachment['id'], $result[$cfId]);
   }
 
+  public function testUpdateCustomField() {
+    $customGroup = $this->customGroupCreate(array('extends' => 'Individual'));
+    $params = array('id' => $customGroup['id'], 'is_active' => 0);
+    $result = $this->callAPISuccess('CustomGroup', 'create', $params);
+    $result = array_shift($result['values']);
+
+    $this->assertEquals(0, $result['is_active']);
+
+    $this->customGroupDelete($customGroup['id']);
+  }
+
+  public function testCustomFieldCreateWithOptionGroupName() {
+    $customGroup = $this->customGroupCreate(array('extends' => 'Individual', 'title' => 'test_custom_group'));
+    $params = array(
+      'custom_group_id' => $customGroup['id'],
+      'name' => 'Activity type',
+      'label' => 'Activity type',
+      'data_type' => 'String',
+      'html_type' => 'Select',
+      'option_group_id' => 'activity_type',
+    );
+    $result = $this->callAPISuccess('CustomField', 'create', $params);
+  }
+
+
   /**
    * @param $getFieldsResult
    *
@@ -558,4 +583,48 @@ class api_v3_CustomFieldTest extends CiviUnitTestCase {
     return $r;
   }
 
+  public function testMakeSearchableContactReferenceFieldUnsearchable() {
+    $customGroup = $this->customGroupCreate(array(
+      'name' => 'testCustomGroup',
+      'title' => 'testCustomGroup',
+      'extends' => 'Individual',
+    ));
+    $params = array(
+      'name' => 'testCustomField',
+      'label' => 'testCustomField',
+      'custom_group_id' => 'testCustomGroup',
+      'data_type' => 'ContactReference',
+      'html_type' => 'Autocomplete-Select',
+      'is_searchable' => '1',
+    );
+    $result = $this->callAPISuccess('CustomField', 'create', $params);
+    $params = [
+      'id' => $result['id'],
+      'is_searchable' => 0,
+    ];
+    $result = $this->callAPISuccess('CustomField', 'create', $params);
+  }
+
+  public function testDisableSearchableContactReferenceField() {
+    $customGroup = $this->customGroupCreate(array(
+      'name' => 'testCustomGroup',
+      'title' => 'testCustomGroup',
+      'extends' => 'Individual',
+    ));
+    $params = array(
+      'name' => 'testCustomField',
+      'label' => 'testCustomField',
+      'custom_group_id' => 'testCustomGroup',
+      'data_type' => 'ContactReference',
+      'html_type' => 'Autocomplete-Select',
+      'is_searchable' => '1',
+    );
+    $result = $this->callAPISuccess('CustomField', 'create', $params);
+    $params = [
+      'id' => $result['id'],
+      'is_active' => 0,
+    ];
+    $result = $this->callAPISuccess('CustomField', 'create', $params);
+  }
+
 }