Coding standards cleanup sprint.
[civicrm-core.git] / tests / phpunit / api / v3 / MembershipTypeTest.php
index 1ccf3be47f4a45151d23f767946f664107e07b25..96c06696954a57b4492e83ef4aabd452d53e2269 100644 (file)
@@ -1,30 +1,29 @@
 <?php
-
 /*
- +--------------------------------------------------------------------+
| CiviCRM version 4.5                                                |
- +--------------------------------------------------------------------+
- | Copyright CiviCRM LLC (c) 2004-2014                                |
- +--------------------------------------------------------------------+
- | 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.   |
- |                                                                    |
- | 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        |
- +--------------------------------------------------------------------+
- */
 +--------------------------------------------------------------------+
 | CiviCRM version 4.6                                                |
 +--------------------------------------------------------------------+
 | Copyright CiviCRM LLC (c) 2004-2014                                |
 +--------------------------------------------------------------------+
 | 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.   |
 |                                                                    |
 | 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        |
 +--------------------------------------------------------------------+
+*/
 
 require_once 'CiviTest/CiviUnitTestCase.php';
 
@@ -37,30 +36,14 @@ class api_v3_MembershipTypeTest extends CiviUnitTestCase {
   protected $_apiversion;
   protected $_entity = 'MembershipType';
 
-
-  /**
-   * @return array
-   */
-  function get_info() {
-    return array(
-      'name' => 'MembershipType Create',
-      'description' => 'Test all Membership Type Create API methods.',
-      'group' => 'CiviCRM API Tests',
-    );
-  }
-
-  function setUp() {
+  public function setUp() {
     parent::setUp();
+    $this->useTransaction(TRUE);
     $this->_apiversion = 3;
     $this->_contactID = $this->organizationCreate(NULL);
   }
 
-  function tearDown() {
-    $tablesToTruncate = array('civicrm_contact');
-    $this->quickCleanup($tablesToTruncate);
-  }
-
-  function testGetWithoutId() {
+  public function testGetWithoutId() {
     $params = array(
       'name' => '60+ Membership',
       'description' => 'people above 60 are given health instructions',
@@ -75,7 +58,7 @@ class api_v3_MembershipTypeTest extends CiviUnitTestCase {
     $this->assertEquals($membershiptype['count'], 0);
   }
 
-  function testGet() {
+  public function testGet() {
     $id = $this->membershipTypeCreate(array('member_of_contact_id' => $this->_contactID));
 
     $params = array(
@@ -91,15 +74,17 @@ class api_v3_MembershipTypeTest extends CiviUnitTestCase {
     $this->membershipTypeDelete($params);
   }
 
-  ///////////////// civicrm_membership_type_create methods
-  function testCreateWithEmptyParams() {
+  /**
+   * Civicrm_membership_type_create methods.
+   */
+  public function testCreateWithEmptyParams() {
     $membershiptype = $this->callAPIFailure('membership_type', 'create', array());
     $this->assertEquals($membershiptype['error_message'],
       'Mandatory key(s) missing from params array: domain_id, member_of_contact_id, financial_type_id, duration_unit, duration_interval, name'
-    );
+                       );
   }
 
-  function testCreateWithoutMemberOfContactId() {
+  public function testCreateWithoutMemberOfContactId() {
     $params = array(
       'name' => '60+ Membership',
       'description' => 'people above 60 are given health instructions',
@@ -113,11 +98,11 @@ class api_v3_MembershipTypeTest extends CiviUnitTestCase {
     );
 
     $membershiptype = $this->callAPIFailure('membership_type', 'create', $params,
-      'Mandatory key(s) missing from params array: member_of_contact_id'
-    );
+                      'Mandatory key(s) missing from params array: member_of_contact_id'
+                                           );
   }
 
-  function testCreateWithoutContributionTypeId() {
+  public function testCreateWithoutContributionTypeId() {
     $params = array(
       'name' => '70+ Membership',
       'description' => 'people above 70 are given health instructions',
@@ -127,14 +112,15 @@ class api_v3_MembershipTypeTest extends CiviUnitTestCase {
       'duration_unit' => 'month',
       'duration_interval' => '10',
       'period_type' => 'rolling',
-      'visibility' => 'public',    );
+      'visibility' => 'public',
+    );
     $membershiptype = $this->callAPIFailure('membership_type', 'create', $params);
     $this->assertEquals($membershiptype['error_message'],
       'Mandatory key(s) missing from params array: financial_type_id'
-    );
+                       );
   }
 
-  function testCreateWithoutDurationUnit() {
+  public function testCreateWithoutDurationUnit() {
     $params = array(
       'name' => '80+ Membership',
       'description' => 'people above 80 are given health instructions',
@@ -143,15 +129,16 @@ class api_v3_MembershipTypeTest extends CiviUnitTestCase {
       'domain_id' => '1',
       'minimum_fee' => '200',
       'duration_interval' => '10',
-      'visibility' => 'public',    );
+      'visibility' => 'public',
+    );
 
     $membershiptype = $this->callAPIFailure('membership_type', 'create', $params);
     $this->assertEquals($membershiptype['error_message'],
       'Mandatory key(s) missing from params array: duration_unit'
-    );
+                       );
   }
 
-  function testCreateWithoutDurationInterval() {
+  public function testCreateWithoutDurationInterval() {
     $params = array(
       'name' => '70+ Membership',
       'description' => 'people above 70 are given health instructions',
@@ -160,14 +147,15 @@ class api_v3_MembershipTypeTest extends CiviUnitTestCase {
       'minimum_fee' => '200',
       'duration_unit' => 'month',
       'period_type' => 'rolling',
-      'visibility' => 'public',    );
+      'visibility' => 'public',
+    );
     $membershiptype = $this->callAPIFailure('membership_type', 'create', $params);
     $this->assertEquals($membershiptype['error_message'],
       'Mandatory key(s) missing from params array: financial_type_id, duration_interval'
-    );
+                       );
   }
 
-  function testCreateWithoutNameandDomainIDandDurationUnit() {
+  public function testCreateWithoutNameandDomainIDandDurationUnit() {
     $params = array(
       'description' => 'people above 50 are given health instructions',
       'member_of_contact_id' => $this->_contactID,
@@ -175,15 +163,16 @@ class api_v3_MembershipTypeTest extends CiviUnitTestCase {
       'minimum_fee' => '200',
       'duration_interval' => '10',
       'period_type' => 'rolling',
-      'visibility' => 'public',    );
+      'visibility' => 'public',
+    );
 
     $membershiptype = $this->callAPIFailure('membership_type', 'create', $params);
     $this->assertEquals($membershiptype['error_message'],
       'Mandatory key(s) missing from params array: domain_id, duration_unit, name'
-    );
+                       );
   }
 
-  function testCreateWithoutName() {
+  public function testCreateWithoutName() {
     $params = array(
       'description' => 'people above 50 are given health instructions',
       'member_of_contact_id' => $this->_contactID,
@@ -193,13 +182,14 @@ class api_v3_MembershipTypeTest extends CiviUnitTestCase {
       'duration_unit' => 'month',
       'duration_interval' => '10',
       'period_type' => 'rolling',
-      'visibility' => 'public',    );
+      'visibility' => 'public',
+    );
 
     $membershiptype = $this->callAPIFailure('membership_type', 'create', $params);
     $this->assertEquals($membershiptype['error_message'], 'Mandatory key(s) missing from params array: name');
   }
 
-  function testCreate() {
+  public function testCreate() {
     $params = array(
       'name' => '40+ Membership',
       'description' => 'people above 40 are given health instructions',
@@ -219,15 +209,15 @@ class api_v3_MembershipTypeTest extends CiviUnitTestCase {
   }
 
 
-  function testUpdateWithEmptyParams() {
+  public function testUpdateWithEmptyParams() {
     $params = array();
     $membershiptype = $this->callAPIFailure('membership_type', 'create', $params);
     $this->assertEquals($membershiptype['error_message'],
       'Mandatory key(s) missing from params array: domain_id, member_of_contact_id, financial_type_id, duration_unit, duration_interval, name'
-    );
+                       );
   }
 
-  function testUpdateWithoutId() {
+  public function testUpdateWithoutId() {
     $params = array(
       'name' => '60+ Membership',
       'description' => 'people above 60 are given health instructions',
@@ -237,18 +227,20 @@ class api_v3_MembershipTypeTest extends CiviUnitTestCase {
       'duration_unit' => 'month',
       'duration_interval' => '10',
       'period_type' => 'rolling',
-      'visibility' => 'public',    );
+      'visibility' => 'public',
+    );
 
     $membershiptype = $this->callAPIFailure('membership_type', 'create', $params);
     $this->assertEquals($membershiptype['error_message'], 'Mandatory key(s) missing from params array: domain_id');
   }
 
-  function testUpdate() {
+  public function testUpdate() {
     $id = $this->membershipTypeCreate(array('member_of_contact_id' => $this->_contactID, 'financial_type_id' => 2));
     $newMembOrgParams = array(
       'organization_name' => 'New membership organisation',
       'contact_type' => 'Organization',
-      'visibility' => 1,    );
+      'visibility' => 1,
+    );
 
     // create a new contact to update this membership type to
     $newMembOrgID = $this->organizationCreate($newMembOrgParams);
@@ -260,23 +252,24 @@ class api_v3_MembershipTypeTest extends CiviUnitTestCase {
       'duration_unit' => 'month',
       'duration_interval' => '10',
       'period_type' => 'fixed',
-      'domain_id' => 1,    );
+      'domain_id' => 1,
+    );
 
     $this->callAPISuccess('membership_type', 'update', $params);
 
     $this->getAndCheck($params, $id, $this->_entity);
   }
 
-  function testDeleteNotExists() {
+  public function testDeleteNotExists() {
     $params = array(
       'id' => 'doesNotExist',
     );
     $membershiptype = $this->callAPIFailure('membership_type', 'delete', $params,
-      'Error while deleting membership type. id : ' . $params['id']
-    );
+                      'Error while deleting membership type. id : ' . $params['id']
+                                           );
   }
 
-  function testDelete() {
+  public function testDelete() {
     $orgID = $this->organizationCreate(NULL);
     $membershipTypeID = $this->membershipTypeCreate(array('member_of_contact_id' => $orgID));
     $params = array(
@@ -286,4 +279,3 @@ class api_v3_MembershipTypeTest extends CiviUnitTestCase {
     $result = $this->callAPIAndDocument('membership_type', 'delete', $params, __FUNCTION__, __FILE__);
   }
 }
-