Minor cleanup in test class
authoreileen <emcnaughton@wikimedia.org>
Sun, 16 Aug 2020 04:23:35 +0000 (16:23 +1200)
committereileen <emcnaughton@wikimedia.org>
Sun, 16 Aug 2020 04:23:35 +0000 (16:23 +1200)
tests/phpunit/api/v3/MembershipTypeTest.php

index 775e0982c451d43db05c5355dbec9455b126fef0..d20a639b6f167a1268d1f91f41b0db94ed0a3bf5 100644 (file)
@@ -15,7 +15,6 @@
  */
 class api_v3_MembershipTypeTest extends CiviUnitTestCase {
   protected $_contactID;
-  protected $_contributionTypeID;
   protected $_entity = 'MembershipType';
 
   /**
@@ -31,7 +30,12 @@ class api_v3_MembershipTypeTest extends CiviUnitTestCase {
    * Get the membership without providing an ID.
    *
    * This should return an empty array but not an error.
+   *
    * @dataProvider versionThreeAndFour
+   *
+   * @param bool $version
+   *
+   * @throws \CRM_Core_Exception
    */
   public function testGetWithoutId($version) {
     $this->_apiversion = $version;
@@ -51,15 +55,15 @@ class api_v3_MembershipTypeTest extends CiviUnitTestCase {
 
   /**
    * Test get works.
+   *
    * @dataProvider versionThreeAndFour
+   *
+   * @param bool $version
    */
   public function testGet($version) {
     $this->_apiversion = $version;
     $id = $this->membershipTypeCreate(['member_of_contact_id' => $this->_contactID]);
-
-    $params = [
-      'id' => $id,
-    ];
+    $params = ['id' => $id];
     $membershipType = $this->callAPIAndDocument('membership_type', 'get', $params, __FUNCTION__, __FILE__);
     $this->assertEquals($membershipType['values'][$id]['name'], 'General');
     $this->assertEquals($membershipType['values'][$id]['member_of_contact_id'], $this->_contactID);
@@ -72,7 +76,10 @@ class api_v3_MembershipTypeTest extends CiviUnitTestCase {
 
   /**
    * Test create with missing mandatory field.
+   *
    * @dataProvider versionThreeAndFour
+   *
+   * @param bool $version
    */
   public function testCreateWithoutMemberOfContactId($version) {
     $this->_apiversion = $version;
@@ -94,7 +101,10 @@ class api_v3_MembershipTypeTest extends CiviUnitTestCase {
 
   /**
    * Test successful create.
+   *
    * @dataProvider versionThreeAndFour
+   *
+   * @param bool $version
    */
   public function testCreate($version) {
     $this->_apiversion = $version;
@@ -119,7 +129,12 @@ class api_v3_MembershipTypeTest extends CiviUnitTestCase {
   /**
    * Domain ID can be intuited..
    * DomainID is now optional on API, check that it gets set correctly and that the domain_id is not overwritten when not specified in create.
+   *
    * @dataProvider versionThreeAndFour
+   *
+   * @param bool $version
+   *
+   * @throws \CRM_Core_Exception
    */
   public function testCreateWithoutDomainId($version) {
     $this->_apiversion = $version;
@@ -151,24 +166,32 @@ class api_v3_MembershipTypeTest extends CiviUnitTestCase {
 
   /**
    *  CRM-20010 Tests period_type is required for MemberType create
+   *
    * @dataProvider versionThreeAndFour
+   *
+   * @param bool $version
    */
   public function testMemberTypePeriodiTypeRequired($version) {
     $this->_apiversion = $version;
     $this->callAPIFailure('MembershipType', 'create', [
-      'domain_id' => "Default Domain Name",
+      'domain_id' => 'Default Domain Name',
       'member_of_contact_id' => 1,
-      'financial_type_id' => "Member Dues",
-      'duration_unit' => "month",
+      'financial_type_id' => 'Member Dues',
+      'duration_unit' => 'month',
       'duration_interval' => 1,
-      'name' => "Standard Member",
+      'name' => 'Standard Member',
       'minimum_fee' => 100,
     ]);
   }
 
   /**
    * Test update.
+   *
    * @dataProvider versionThreeAndFour
+   *
+   * @param bool $version
+   *
+   * @throws \CRM_Core_Exception
    */
   public function testUpdate($version) {
     $this->_apiversion = $version;
@@ -196,15 +219,15 @@ class api_v3_MembershipTypeTest extends CiviUnitTestCase {
 
   /**
    * Test successful delete.
+   *
    * @dataProvider versionThreeAndFour
+   *
+   * @param bool $version
    */
   public function testDelete($version) {
     $this->_apiversion = $version;
     $membershipTypeID = $this->membershipTypeCreate(['member_of_contact_id' => $this->organizationCreate()]);
-    $params = [
-      'id' => $membershipTypeID,
-    ];
-
+    $params = ['id' => $membershipTypeID];
     $this->callAPIAndDocument('membership_type', 'delete', $params, __FUNCTION__, __FILE__);
   }
 
@@ -269,11 +292,11 @@ class api_v3_MembershipTypeTest extends CiviUnitTestCase {
     $memType = [];
     $memType[1] = $this->membershipTypeCreate(['member_of_contact_id' => $this->_contactID, 'minimum_fee' => 100]);
     $priceSet = $this->callAPISuccess('price_set', 'create', [
-      'title' => "test priceset",
-      'name' => "test_priceset",
-      'extends' => "CiviMember",
+      'title' => 'test priceset',
+      'name' => 'test_priceset',
+      'extends' => 'CiviMember',
       'is_quick_config' => 1,
-      'financial_type_id' => "Member Dues",
+      'financial_type_id' => 'Member Dues',
     ]);
     $priceSet = $priceSet['id'];
     $field = $this->callAPISuccess('price_field', 'create', [
@@ -327,7 +350,7 @@ class api_v3_MembershipTypeTest extends CiviUnitTestCase {
     ]);
     //Verify if membership type updates are copied to pricefield value.
     foreach ($priceFieldValue['values'] as $key => $value) {
-      $setId = $this->callAPISuccessGetValue('PriceField', ['return' => "price_set_id", 'id' => $value['price_field_id']]);
+      $setId = $this->callAPISuccessGetValue('PriceField', ['return' => 'price_set_id', 'id' => $value['price_field_id']]);
       if ($setId == $priceSet) {
         $this->assertEquals($value['label'], $updateParams['name']);
         $this->assertEquals($value['description'], $updateParams['description']);