X-Git-Url: https://vcs.fsf.org/?a=blobdiff_plain;f=tests%2Fphpunit%2Fapi%2Fv3%2FCustomGroupTest.php;h=4816f1157ddea0db04051b1dd44a53e09456c2aa;hb=0e87954f62c4fa1c54d72c1cd2d47dc84f9e5201;hp=e93934c1b018b9bf775d5b26c09651528aa700dc;hpb=e403ec0e66ed8967d5ae0ff248d22f1b3c41004c;p=civicrm-core.git diff --git a/tests/phpunit/api/v3/CustomGroupTest.php b/tests/phpunit/api/v3/CustomGroupTest.php index e93934c1b0..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; @@ -42,9 +41,9 @@ class api_v3_CustomGroupTest extends CiviUnitTestCase { public $DBResetRequired = TRUE; - function setUp() { - $this->_entity = 'CustomGroup'; - $this->_params = array( + public function setUp() { + $this->_entity = 'CustomGroup'; + $this->_params = array( 'title' => 'Test_Group_1', 'name' => 'test_group_1', 'extends' => 'Individual', @@ -58,7 +57,7 @@ class api_v3_CustomGroupTest extends CiviUnitTestCase { parent::setUp(); } - function tearDown() { + public function tearDown() { $tablesToTruncate = array('civicrm_custom_group', 'civicrm_custom_field'); // true tells quickCleanup to drop any tables that might have been created in the test $this->quickCleanup($tablesToTruncate, TRUE); @@ -67,21 +66,21 @@ 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) */ - function testCustomGroupCreateNoParam() { + public function testCustomGroupCreateNoParam() { $customGroup = $this->callAPIFailure('custom_group', 'create', array(), 'Mandatory key(s) missing from params array: title, extends' ); } /** - * Check with empty array + * Check with empty array. */ - function testCustomGroupCreateNoExtends() { + public function testCustomGroupCreateNoExtends() { $params = array( 'domain_id' => 1, 'title' => 'Test_Group_1', @@ -95,14 +94,14 @@ 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. */ - function testCustomGroupCreateInvalidExtends() { + public function testCustomGroupCreateInvalidExtends() { $params = array( 'domain_id' => 1, 'title' => 'Test_Group_1', @@ -117,13 +116,13 @@ 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. */ - function testCustomGroupCreateExtendsString() { + public function testCustomGroupCreateExtendsString() { $params = array( 'domain_id' => 1, 'title' => 'Test_Group_1', @@ -141,9 +140,9 @@ class api_v3_CustomGroupTest extends CiviUnitTestCase { } /** - * Check with valid array + * Check with valid array. */ - function testCustomGroupCreate() { + public function testCustomGroupCreate() { $params = array( 'title' => 'Test_Group_1', 'name' => 'test_group_1', @@ -157,14 +156,14 @@ 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. */ - function testCustomGroupGetFields() { + public function testCustomGroupGetFields() { $params = array( 'options' => array('get_options' => 'style'), ); @@ -181,7 +180,7 @@ class api_v3_CustomGroupTest extends CiviUnitTestCase { /** * Check with extends array length greater than 1 */ - function testCustomGroupExtendsMultipleCreate() { + public function testCustomGroupExtendsMultipleCreate() { $params = array( 'title' => 'Test_Group_1', 'name' => 'test_group_1', @@ -195,13 +194,13 @@ 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. */ - function testCustomGroupCreateNoStyle() { + public function testCustomGroupCreateNoStyle() { $params = array( 'title' => 'Test_Group_1', 'name' => 'test_group_1', @@ -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. */ - function testCustomGroupCreateNotArray() { + 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. */ - function testCustomGroupCreateNoTitle() { - $params = array('extends' => array('Contact'), + public function testCustomGroupCreateNoTitle() { + $params = array( + 'extends' => array('Contact'), 'weight' => 5, 'collapse_display' => 1, 'style' => 'Tab', @@ -244,9 +244,9 @@ class api_v3_CustomGroupTest extends CiviUnitTestCase { } /** - * Check for household without weight + * Check for household without weight. */ - function testCustomGroupCreateHouseholdNoWeight() { + public function testCustomGroupCreateHouseholdNoWeight() { $params = array( 'title' => 'Test_Group_3', 'name' => 'test_group_3', @@ -259,15 +259,15 @@ 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. */ - function testCustomGroupCreateContributionDonation() { + public function testCustomGroupCreateContributionDonation() { $params = array( 'title' => 'Test_Group_6', 'name' => 'test_group_6', @@ -281,14 +281,14 @@ 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. */ - function testCustomGroupCreateGroup() { + public function testCustomGroupCreateGroup() { $params = array( 'domain_id' => 1, 'title' => 'Test_Group_8', @@ -303,14 +303,14 @@ 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'); } /** * Check with Activity - Meeting Type */ - function testCustomGroupCreateActivityMeeting() { + public function testCustomGroupCreateActivityMeeting() { $params = array( 'title' => 'Test_Group_10', 'name' => 'test_group_10', @@ -323,33 +323,33 @@ 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. */ - function testCustomGroupDeleteWithoutGroupID() { + 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. */ - function testCustomGroupDeleteNoArray() { + 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. */ - function testCustomGroupDelete() { + public function testCustomGroupDelete() { $customGroup = $this->customGroupCreate(array('extends' => 'Individual', 'title' => 'test_group')); $params = array( 'id' => $customGroup['id'], @@ -359,7 +359,7 @@ class api_v3_CustomGroupTest extends CiviUnitTestCase { } /** - * Main success get function + * Main success get function. */ public function testGetCustomGroupSuccess() { @@ -374,5 +374,5 @@ class api_v3_CustomGroupTest extends CiviUnitTestCase { $this->assertEquals($value, $values[$key], $key . " doesn't match " . print_r($values, TRUE) . 'in line' . __LINE__); } } -} +}