INFRA-132 - tests/ - phpcbf
[civicrm-core.git] / tests / phpunit / api / v3 / MembershipTypeTest.php
index 4985db24f1efe86b4dd9e1ec4ba6a2ea805576e9..103a673b86ed338b716831b9e412361ade2e7c13 100644 (file)
@@ -2,7 +2,7 @@
 
 /*
  +--------------------------------------------------------------------+
- | CiviCRM version 4.5                                                |
+ | CiviCRM version 4.6                                                |
  +--------------------------------------------------------------------+
  | Copyright CiviCRM LLC (c) 2004-2014                                |
  +--------------------------------------------------------------------+
  */
 
 require_once 'CiviTest/CiviUnitTestCase.php';
+
+/**
+ * Class api_v3_MembershipTypeTest
+ */
 class api_v3_MembershipTypeTest extends CiviUnitTestCase {
   protected $_contactID;
   protected $_contributionTypeID;
   protected $_apiversion;
   protected $_entity = 'MembershipType';
 
-
-  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',
@@ -68,7 +59,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(
@@ -85,14 +76,14 @@ class api_v3_MembershipTypeTest extends CiviUnitTestCase {
   }
 
   ///////////////// civicrm_membership_type_create methods
-  function testCreateWithEmptyParams() {
+  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',
@@ -110,7 +101,7 @@ class api_v3_MembershipTypeTest extends CiviUnitTestCase {
     );
   }
 
-  function testCreateWithoutContributionTypeId() {
+  public function testCreateWithoutContributionTypeId() {
     $params = array(
       'name' => '70+ Membership',
       'description' => 'people above 70 are given health instructions',
@@ -120,14 +111,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: financial_type_id'
     );
   }
 
-  function testCreateWithoutDurationUnit() {
+  public function testCreateWithoutDurationUnit() {
     $params = array(
       'name' => '80+ Membership',
       'description' => 'people above 80 are given health instructions',
@@ -136,7 +127,7 @@ 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'],
@@ -144,7 +135,7 @@ class api_v3_MembershipTypeTest extends CiviUnitTestCase {
     );
   }
 
-  function testCreateWithoutDurationInterval() {
+  public function testCreateWithoutDurationInterval() {
     $params = array(
       'name' => '70+ Membership',
       'description' => 'people above 70 are given health instructions',
@@ -153,14 +144,14 @@ 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,
@@ -168,7 +159,7 @@ 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'],
@@ -176,7 +167,7 @@ class api_v3_MembershipTypeTest extends CiviUnitTestCase {
     );
   }
 
-  function testCreateWithoutName() {
+  public function testCreateWithoutName() {
     $params = array(
       'description' => 'people above 50 are given health instructions',
       'member_of_contact_id' => $this->_contactID,
@@ -186,13 +177,13 @@ 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',
@@ -212,7 +203,7 @@ 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'],
@@ -220,7 +211,7 @@ class api_v3_MembershipTypeTest extends CiviUnitTestCase {
     );
   }
 
-  function testUpdateWithoutId() {
+  public function testUpdateWithoutId() {
     $params = array(
       'name' => '60+ Membership',
       'description' => 'people above 60 are given health instructions',
@@ -230,18 +221,18 @@ 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);
@@ -253,14 +244,14 @@ 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',
     );
@@ -269,7 +260,7 @@ class api_v3_MembershipTypeTest extends CiviUnitTestCase {
     );
   }
 
-  function testDelete() {
+  public function testDelete() {
     $orgID = $this->organizationCreate(NULL);
     $membershipTypeID = $this->membershipTypeCreate(array('member_of_contact_id' => $orgID));
     $params = array(
@@ -279,4 +270,3 @@ class api_v3_MembershipTypeTest extends CiviUnitTestCase {
     $result = $this->callAPIAndDocument('membership_type', 'delete', $params, __FUNCTION__, __FILE__);
   }
 }
-