Add in Country and StateProvince APIv4 Entities
[civicrm-core.git] / tests / phpunit / api / v3 / UFFieldTest.php
index 68e5610824cbcfea31b44d16ce18d523d1db2a2a..15ef6ec1bec5ba3a7e6c2e212108052fe6efd253 100644 (file)
@@ -1,34 +1,16 @@
 <?php
 /*
  +--------------------------------------------------------------------+
- | CiviCRM version 5                                                  |
- +--------------------------------------------------------------------+
- | Copyright CiviCRM LLC (c) 2004-2019                                |
- +--------------------------------------------------------------------+
- | This file is a part of CiviCRM.                                    |
- |                                                                    |
- | CiviCRM is free software; you can copy, modify, and distribute it  |
- | under the terms of the GNU Affero General Public License           |
- | Version 3, 19 November 2007 and the CiviCRM Licensing Exception.   |
+ | Copyright CiviCRM LLC. All rights reserved.                        |
  |                                                                    |
- | CiviCRM is distributed in the hope that it will be useful, but     |
- | WITHOUT ANY WARRANTY; without even the implied warranty of         |
- | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.               |
- | See the GNU Affero General Public License for more details.        |
- |                                                                    |
- | You should have received a copy of the GNU Affero General Public   |
- | License and the CiviCRM Licensing Exception along                  |
- | with this program; if not, contact CiviCRM LLC                     |
- | at info[AT]civicrm[DOT]org. If you have questions about the        |
- | GNU Affero General Public License or the licensing of CiviCRM,     |
- | see the CiviCRM license FAQ at http://civicrm.org/licensing        |
+ | This work is published under the GNU AGPLv3 license with some      |
+ | permitted exceptions and without any warranty. For full license    |
+ | and copyright information, see https://civicrm.org/licensing       |
  +--------------------------------------------------------------------+
  */
 
 /**
- * Test class for UFGroup API - civicrm_uf_*
- *
- * @todo Split UFGroup and UFJoin tests
+ * Test class for UFField API
  *
  * @package   CiviCRM
  * @group headless
@@ -105,8 +87,11 @@ class api_v3_UFFieldTest extends CiviUnitTestCase {
 
   /**
    * Create / updating field.
+   * @param int $version
+   * @dataProvider versionThreeAndFour
    */
-  public function testCreateUFField() {
+  public function testCreateUFField($version) {
+    $this->_apiversion = $version;
     $params = $this->_params;
     $ufField = $this->callAPIAndDocument('uf_field', 'create', $params, __FUNCTION__, __FILE__);
     unset($params['uf_group_id']);
@@ -118,8 +103,11 @@ class api_v3_UFFieldTest extends CiviUnitTestCase {
 
   /**
    * Failure test for field_name.
+   * @param int $version
+   * @dataProvider versionThreeAndFour
    */
-  public function testCreateUFFieldWithBadFieldName() {
+  public function testCreateUFFieldWithBadFieldName($version) {
+    $this->_apiversion = $version;
     $params = $this->_params;
     $params['field_name'] = 'custom_98789';
     $this->callAPIFailure('uf_field', 'create', $params);
@@ -127,8 +115,11 @@ class api_v3_UFFieldTest extends CiviUnitTestCase {
 
   /**
    * Failure test for bad parameters.
+   * @param int $version
+   * @dataProvider versionThreeAndFour
    */
-  public function testCreateUFFieldWithWrongParams() {
+  public function testCreateUFFieldWithWrongParams($version) {
+    $this->_apiversion = $version;
     $this->callAPIFailure('uf_field', 'create', ['field_name' => 'test field']);
     $this->callAPIFailure('uf_field', 'create', ['label' => 'name-less field']);
   }
@@ -137,8 +128,11 @@ class api_v3_UFFieldTest extends CiviUnitTestCase {
    * 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'.
+   * @param int $version
+   * @dataProvider versionThreeAndFour
    */
-  public function testCreateUFFieldWithDefaultAutoWeight() {
+  public function testCreateUFFieldWithDefaultAutoWeight($version) {
+    $this->_apiversion = $version;
     $params1 = $this->_params;
     $ufField1 = $this->callAPISuccess('uf_field', 'create', $params1);
     $this->assertEquals(1, $ufField1['values'][$ufField1['id']]['weight']);
@@ -161,8 +155,11 @@ class api_v3_UFFieldTest extends CiviUnitTestCase {
 
   /**
    * Deleting field.
+   * @param int $version
+   * @dataProvider versionThreeAndFour
    */
-  public function testDeleteUFField() {
+  public function testDeleteUFField($version) {
+    $this->_apiversion = $version;
     $ufField = $this->callAPISuccess('uf_field', 'create', $this->_params);
     $params = [
       'field_id' => $ufField['id'],
@@ -172,8 +169,11 @@ class api_v3_UFFieldTest extends CiviUnitTestCase {
 
   /**
    * Test getting ufField.
+   * @param int $version
+   * @dataProvider versionThreeAndFour
    */
-  public function testGetUFFieldSuccess() {
+  public function testGetUFFieldSuccess($version) {
+    $this->_apiversion = $version;
     $this->callAPISuccess($this->_entity, 'create', $this->_params);
     $result = $this->callAPIAndDocument($this->_entity, 'get', [], __FUNCTION__, __FILE__);
     $this->getAndCheck($this->_params, $result['id'], $this->_entity);
@@ -243,8 +243,11 @@ class api_v3_UFFieldTest extends CiviUnitTestCase {
 
   /**
    * Check Profile API permission without ACL.
+   * @param int $version
+   * @dataProvider versionThreeAndFour
    */
-  public function testProfilesWithoutACL() {
+  public function testProfilesWithoutACL($version) {
+    $this->_apiversion = $version;
     $this->createLoggedInUser();
     $baseFields[] = [
       'field_name' => 'first_name',