X-Git-Url: https://vcs.fsf.org/?a=blobdiff_plain;f=tests%2Fphpunit%2Fapi%2Fv3%2FCustomGroupTest.php;h=4816f1157ddea0db04051b1dd44a53e09456c2aa;hb=0e87954f62c4fa1c54d72c1cd2d47dc84f9e5201;hp=d387c1964cde4cab4fd19b11cd0d629e1f2f5001;hpb=ef10e0b52408ba266239a859756d757a10348228;p=civicrm-core.git diff --git a/tests/phpunit/api/v3/CustomGroupTest.php b/tests/phpunit/api/v3/CustomGroupTest.php index d387c1964c..4816f1157d 100644 --- a/tests/phpunit/api/v3/CustomGroupTest.php +++ b/tests/phpunit/api/v3/CustomGroupTest.php @@ -3,7 +3,7 @@ +--------------------------------------------------------------------+ | CiviCRM version 4.6 | +--------------------------------------------------------------------+ - | Copyright CiviCRM LLC (c) 2004-2014 | + | Copyright CiviCRM LLC (c) 2004-2015 | +--------------------------------------------------------------------+ | This file is a part of CiviCRM. | | | @@ -23,7 +23,7 @@ | GNU Affero General Public License or the licensing of CiviCRM, | | see the CiviCRM license FAQ at http://civicrm.org/licensing | +--------------------------------------------------------------------+ -*/ + */ require_once 'CiviTest/CiviUnitTestCase.php'; @@ -31,10 +31,9 @@ require_once 'CiviTest/CiviUnitTestCase.php'; /** * Test APIv3 civicrm_custom_group* functions * - * @package CiviCRM_APIv3 - * @subpackage API_CustomGroup + * @package CiviCRM_APIv3 + * @subpackage API_CustomGroup */ - class api_v3_CustomGroupTest extends CiviUnitTestCase { protected $_apiversion = 3; protected $_entity; @@ -43,8 +42,8 @@ class api_v3_CustomGroupTest extends CiviUnitTestCase { public $DBResetRequired = TRUE; public function setUp() { - $this->_entity = 'CustomGroup'; - $this->_params = array( + $this->_entity = 'CustomGroup'; + $this->_params = array( 'title' => 'Test_Group_1', 'name' => 'test_group_1', 'extends' => 'Individual', @@ -67,7 +66,7 @@ class api_v3_CustomGroupTest extends CiviUnitTestCase { ///////////////// civicrm_custom_group_create methods /** - * Check with empty array + * Check with empty array. * note that these tests are of marginal value so should not be included in copy & paste * code. The SyntaxConformance is capable of testing this for all entities on create * & delete (& it would be easy to add if not there) @@ -79,7 +78,7 @@ class api_v3_CustomGroupTest extends CiviUnitTestCase { } /** - * Check with empty array + * Check with empty array. */ public function testCustomGroupCreateNoExtends() { $params = array( @@ -95,12 +94,12 @@ class api_v3_CustomGroupTest extends CiviUnitTestCase { ); $customGroup = $this->callAPIFailure('custom_group', 'create', $params); - $this->assertEquals($customGroup['error_message'], 'Mandatory key(s) missing from params array: extends', 'In line ' . __LINE__); + $this->assertEquals($customGroup['error_message'], 'Mandatory key(s) missing from params array: extends'); $this->assertAPIFailure($customGroup, 'In line ' . __LINE__); } /** - * Check with empty array + * Check with empty array. */ public function testCustomGroupCreateInvalidExtends() { $params = array( @@ -117,11 +116,11 @@ class api_v3_CustomGroupTest extends CiviUnitTestCase { ); $customGroup = $this->callAPIFailure('custom_group', 'create', $params); - $this->assertEquals($customGroup['error_message'], 'Mandatory key(s) missing from params array: extends', 'In line ' . __LINE__); + $this->assertEquals($customGroup['error_message'], 'Mandatory key(s) missing from params array: extends'); } /** - * Check with a string instead of array for extends + * Check with a string instead of array for extends. */ public function testCustomGroupCreateExtendsString() { $params = array( @@ -141,7 +140,7 @@ class api_v3_CustomGroupTest extends CiviUnitTestCase { } /** - * Check with valid array + * Check with valid array. */ public function testCustomGroupCreate() { $params = array( @@ -157,12 +156,12 @@ class api_v3_CustomGroupTest extends CiviUnitTestCase { ); $result = $this->callAPIAndDocument('custom_group', 'create', $params, __FUNCTION__, __FILE__); - $this->assertNotNull($result['id'], 'In line ' . __LINE__); - $this->assertEquals($result['values'][$result['id']]['extends'], 'Individual', 'In line ' . __LINE__); + $this->assertNotNull($result['id']); + $this->assertEquals($result['values'][$result['id']]['extends'], 'Individual'); } /** - * Check with valid array + * Check with valid array. */ public function testCustomGroupGetFields() { $params = array( @@ -195,11 +194,11 @@ class api_v3_CustomGroupTest extends CiviUnitTestCase { ); $result = $this->callAPIFailure('custom_group', 'create', $params, - 'implode(): Invalid arguments passed'); + 'implode(): Invalid arguments passed'); } /** - * Check with style missing from params array + * Check with style missing from params array. */ public function testCustomGroupCreateNoStyle() { $params = array( @@ -214,24 +213,25 @@ class api_v3_CustomGroupTest extends CiviUnitTestCase { ); $customGroup = $this->callAPISuccess('custom_group', 'create', $params); - $this->assertNotNull($customGroup['id'], 'In line ' . __LINE__); - $this->assertEquals($customGroup['values'][$customGroup['id']]['style'], 'Inline', 'In line ' . __LINE__); + $this->assertNotNull($customGroup['id']); + $this->assertEquals($customGroup['values'][$customGroup['id']]['style'], 'Inline'); } /** - * Check with not array + * Check with not array. */ public function testCustomGroupCreateNotArray() { $params = NULL; $customGroup = $this->callAPIFailure('custom_group', 'create', $params); - $this->assertEquals($customGroup['error_message'], 'Input variable `params` is not an array', 'In line ' . __LINE__); + $this->assertEquals($customGroup['error_message'], 'Input variable `params` is not an array'); } /** - * Check without title + * Check without title. */ public function testCustomGroupCreateNoTitle() { - $params = array('extends' => array('Contact'), + $params = array( + 'extends' => array('Contact'), 'weight' => 5, 'collapse_display' => 1, 'style' => 'Tab', @@ -244,7 +244,7 @@ class api_v3_CustomGroupTest extends CiviUnitTestCase { } /** - * Check for household without weight + * Check for household without weight. */ public function testCustomGroupCreateHouseholdNoWeight() { $params = array( @@ -259,13 +259,13 @@ class api_v3_CustomGroupTest extends CiviUnitTestCase { ); $customGroup = $this->callAPISuccess('custom_group', 'create', $params); - $this->assertNotNull($customGroup['id'], 'In line ' . __LINE__); - $this->assertEquals($customGroup['values'][$customGroup['id']]['extends'], 'Household', 'In line ' . __LINE__); - $this->assertEquals($customGroup['values'][$customGroup['id']]['style'], 'Tab', 'In line ' . __LINE__); + $this->assertNotNull($customGroup['id']); + $this->assertEquals($customGroup['values'][$customGroup['id']]['extends'], 'Household'); + $this->assertEquals($customGroup['values'][$customGroup['id']]['style'], 'Tab'); } /** - * Check for Contribution Donation + * Check for Contribution Donation. */ public function testCustomGroupCreateContributionDonation() { $params = array( @@ -281,12 +281,12 @@ class api_v3_CustomGroupTest extends CiviUnitTestCase { ); $customGroup = $this->callAPISuccess('custom_group', 'create', $params); - $this->assertNotNull($customGroup['id'], 'In line ' . __LINE__); - $this->assertEquals($customGroup['values'][$customGroup['id']]['extends'], 'Contribution', 'In line ' . __LINE__); + $this->assertNotNull($customGroup['id']); + $this->assertEquals($customGroup['values'][$customGroup['id']]['extends'], 'Contribution'); } /** - * Check with valid array + * Check with valid array. */ public function testCustomGroupCreateGroup() { $params = array( @@ -303,8 +303,8 @@ class api_v3_CustomGroupTest extends CiviUnitTestCase { ); $customGroup = $this->callAPISuccess('custom_group', 'create', $params); - $this->assertNotNull($customGroup['id'], 'In line ' . __LINE__); - $this->assertEquals($customGroup['values'][$customGroup['id']]['extends'], 'Group', 'In line ' . __LINE__); + $this->assertNotNull($customGroup['id']); + $this->assertEquals($customGroup['values'][$customGroup['id']]['extends'], 'Group'); } /** @@ -323,31 +323,31 @@ class api_v3_CustomGroupTest extends CiviUnitTestCase { ); $customGroup = $this->callAPISuccess('custom_group', 'create', $params); - $this->assertNotNull($customGroup['id'], 'In line ' . __LINE__); - $this->assertEquals($customGroup['values'][$customGroup['id']]['extends'], 'Activity', 'In line ' . __LINE__); + $this->assertNotNull($customGroup['id']); + $this->assertEquals($customGroup['values'][$customGroup['id']]['extends'], 'Activity'); } ///////////////// civicrm_custom_group_delete methods /** - * Check without GroupID + * Check without GroupID. */ public function testCustomGroupDeleteWithoutGroupID() { $customGroup = $this->callAPIFailure('custom_group', 'delete', array()); - $this->assertEquals($customGroup['error_message'], 'Mandatory key(s) missing from params array: id', 'In line ' . __LINE__); + $this->assertEquals($customGroup['error_message'], 'Mandatory key(s) missing from params array: id'); } /** - * Check with no array + * Check with no array. */ public function testCustomGroupDeleteNoArray() { $params = NULL; $customGroup = $this->callAPIFailure('custom_group', 'delete', $params); - $this->assertEquals($customGroup['error_message'], 'Input variable `params` is not an array', 'In line ' . __LINE__); + $this->assertEquals($customGroup['error_message'], 'Input variable `params` is not an array'); } /** - * Check with valid custom group id + * Check with valid custom group id. */ public function testCustomGroupDelete() { $customGroup = $this->customGroupCreate(array('extends' => 'Individual', 'title' => 'test_group')); @@ -359,7 +359,7 @@ class api_v3_CustomGroupTest extends CiviUnitTestCase { } /** - * Main success get function + * Main success get function. */ public function testGetCustomGroupSuccess() { @@ -374,4 +374,5 @@ class api_v3_CustomGroupTest extends CiviUnitTestCase { $this->assertEquals($value, $values[$key], $key . " doesn't match " . print_r($values, TRUE) . 'in line' . __LINE__); } } + }