X-Git-Url: https://vcs.fsf.org/?a=blobdiff_plain;f=tests%2Fphpunit%2Fapi%2Fv3%2FCustomGroupTest.php;h=4816f1157ddea0db04051b1dd44a53e09456c2aa;hb=0e87954f62c4fa1c54d72c1cd2d47dc84f9e5201;hp=8d44de6980eb17e077ef0d2189e6ab2513752053;hpb=d69fa047cdc76b337124f93354abb2e1bf207a58;p=civicrm-core.git diff --git a/tests/phpunit/api/v3/CustomGroupTest.php b/tests/phpunit/api/v3/CustomGroupTest.php index 8d44de6980..4816f1157d 100644 --- a/tests/phpunit/api/v3/CustomGroupTest.php +++ b/tests/phpunit/api/v3/CustomGroupTest.php @@ -1,9 +1,9 @@ 'Custom Group Create', - 'description' => 'Test all Custom Group Create API methods.', - 'group' => 'CiviCRM API Tests', - ); - } - - 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', @@ -69,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); @@ -78,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', @@ -106,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', @@ -128,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', @@ -152,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', @@ -168,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'), ); @@ -192,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', @@ -206,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', @@ -225,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', @@ -255,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', @@ -270,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', @@ -292,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', @@ -314,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', @@ -334,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'], @@ -370,7 +359,7 @@ class api_v3_CustomGroupTest extends CiviUnitTestCase { } /** - * Main success get function + * Main success get function. */ public function testGetCustomGroupSuccess() { @@ -385,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__); } } -} +}