tests/phpunit - Declare `@group headless`
[civicrm-core.git] / tests / phpunit / api / v3 / UFFieldTest.php
index 48f076376ce2dc2c47ae7878d010bb19af2d1de9..7e9eabb10377a27df89349f25634289533fe06d4 100644 (file)
  +--------------------------------------------------------------------+
  */
 
-
-require_once 'CiviTest/CiviUnitTestCase.php';
-
 /**
  * Test class for UFGroup API - civicrm_uf_*
  * @todo Split UFGroup and UFJoin tests
  *
  * @package   CiviCRM
+ * @group headless
  */
 class api_v3_UFFieldTest extends CiviUnitTestCase {
   // ids from the uf_group_test.xml fixture
@@ -43,7 +41,11 @@ class api_v3_UFFieldTest extends CiviUnitTestCase {
   protected $_params;
   protected $_entity = 'uf_field';
 
-
+  /**
+   * Set up for test.
+   *
+   * @throws \Exception
+   */
   protected function setUp() {
     parent::setUp();
     $this->quickCleanup(
@@ -79,6 +81,11 @@ class api_v3_UFFieldTest extends CiviUnitTestCase {
     );
   }
 
+  /**
+   * Tear down function.
+   *
+   * @throws \Exception
+   */
   public function tearDown() {
     $this->quickCleanup(
       array(
@@ -92,10 +99,10 @@ class api_v3_UFFieldTest extends CiviUnitTestCase {
   }
 
   /**
-   * Create / updating field
+   * Create / updating field.
    */
   public function testCreateUFField() {
-    $params = $this->_params; // copy
+    $params = $this->_params;
     $ufField = $this->callAPIAndDocument('uf_field', 'create', $params, __FUNCTION__, __FILE__);
     unset($params['uf_group_id']);
     $this->_ufFieldId = $ufField['id'];
@@ -104,31 +111,39 @@ class api_v3_UFFieldTest extends CiviUnitTestCase {
     }
   }
 
+  /**
+   * Failure test for field_name.
+   */
   public function testCreateUFFieldWithBadFieldName() {
-    $params = $this->_params; // copy
-    $params['field_name'] = 'custom_98789'; // invalid field
+    $params = $this->_params;
+    $params['field_name'] = 'custom_98789';
     $this->callAPIFailure('uf_field', 'create', $params);
   }
 
+  /**
+   * Failure test for bad parameters.
+   */
   public function testCreateUFFieldWithWrongParams() {
     $this->callAPIFailure('uf_field', 'create', array('field_name' => 'test field'));
     $this->callAPIFailure('uf_field', 'create', array('label' => 'name-less field'));
   }
 
   /**
-   * Create a field with 'weight=1' and then a second with 'weight=1'. The second field
-   * winds up with weight=1, and the first field gets bumped to 'weight=2'.
+   * Create a field with 'weight=1' and then a second with 'weight=1'.
+   *
+   * The second field winds up with weight=1, and the first field gets bumped to 'weight=2'.
    */
   public function testCreateUFFieldWithDefaultAutoWeight() {
-    $params1 = $this->_params; // copy
+    $params1 = $this->_params;
     $ufField1 = $this->callAPISuccess('uf_field', 'create', $params1);
     $this->assertEquals(1, $ufField1['values'][$ufField1['id']]['weight']);
     $this->assertDBQuery(1, 'SELECT weight FROM civicrm_uf_field WHERE id = %1', array(
       1 => array($ufField1['id'], 'Int'),
     ));
 
-    $params2 = $this->_params; // copy
-    $params2['location_type_id'] = 2; // needs to be a different field
+    $params2 = $this->_params;
+    // needs to be a different field
+    $params2['location_type_id'] = 2;
     $ufField2 = $this->callAPISuccess('uf_field', 'create', $params2);
     $this->assertEquals(1, $ufField2['values'][$ufField2['id']]['weight']);
     $this->assertDBQuery(1, 'SELECT weight FROM civicrm_uf_field WHERE id = %1', array(
@@ -147,9 +162,12 @@ class api_v3_UFFieldTest extends CiviUnitTestCase {
     $params = array(
       'field_id' => $ufField['id'],
     );
-    $result = $this->callAPIAndDocument('uf_field', 'delete', $params, __FUNCTION__, __FILE__);
+    $this->callAPIAndDocument('uf_field', 'delete', $params, __FUNCTION__, __FILE__);
   }
 
+  /**
+   * Test getting ufField.
+   */
   public function testGetUFFieldSuccess() {
     $this->callAPISuccess($this->_entity, 'create', $this->_params);
     $result = $this->callAPIAndDocument($this->_entity, 'get', array(), __FUNCTION__, __FILE__);
@@ -157,7 +175,7 @@ class api_v3_UFFieldTest extends CiviUnitTestCase {
   }
 
   /**
-   * Create / updating field
+   * Create / updating field.
    */
   public function testReplaceUFFields() {
     $baseFields = array();
@@ -240,7 +258,7 @@ class api_v3_UFFieldTest extends CiviUnitTestCase {
       'check_permissions' => TRUE,
     );
     $this->_loggedInUser = CRM_Core_Session::singleton()->get('userID');
-    $result = $this->callAPIFailure('uf_field', 'replace', $params);
+    $this->callAPIFailure('uf_field', 'replace', $params);
   }
 
   /**