[NFC] Remove all the places where tests unnecessarily pass to Membership::create
authoreileen <emcnaughton@wikimedia.org>
Thu, 16 Apr 2020 06:04:27 +0000 (18:04 +1200)
committereileen <emcnaughton@wikimedia.org>
Thu, 16 Apr 2020 06:04:27 +0000 (18:04 +1200)
The param is deprecated - no reasonn to pass in the tests

tests/phpunit/CRM/Member/BAO/MembershipTest.php
tests/phpunit/CRM/Member/BAO/MembershipTypeTest.php
tests/phpunit/api/v3/MembershipTest.php

index f8b57375eb664384dd7b869ba18a1d28b511a2bb..8e0307e799d6365895c9bbd6e32f79e344989a5e 100644 (file)
@@ -131,6 +131,7 @@ class CRM_Member_BAO_MembershipTest extends CiviUnitTestCase {
 
     // Now call create() to modify an existing Membership
     $params = [
+      'id' => $membershipId,
       'contact_id' => $contactId,
       'membership_type_id' => $this->_membershipTypeID,
       'join_date' => date('Ymd', strtotime('2006-01-21')),
@@ -140,10 +141,7 @@ class CRM_Member_BAO_MembershipTest extends CiviUnitTestCase {
       'is_override' => 1,
       'status_id' => $this->_membershipStatusID,
     ];
-    $ids = [
-      'membership' => $membershipId,
-    ];
-    CRM_Member_BAO_Membership::create($params, $ids);
+    CRM_Member_BAO_Membership::create($params);
 
     $membershipTypeId = $this->assertDBNotNull('CRM_Member_BAO_Membership', $contactId,
       'membership_type_id', 'contact_id',
@@ -176,8 +174,7 @@ class CRM_Member_BAO_MembershipTest extends CiviUnitTestCase {
       'status_id' => $this->_membershipStatusID,
     ];
 
-    $ids = [];
-    CRM_Member_BAO_Membership::create($params, $ids);
+    CRM_Member_BAO_Membership::create($params);
 
     $membershipId1 = $this->assertDBNotNull('CRM_Member_BAO_Membership', $contactId, 'id',
       'contact_id', 'Database check for created membership.'
@@ -193,8 +190,8 @@ class CRM_Member_BAO_MembershipTest extends CiviUnitTestCase {
       'is_override' => 0,
       'status_id' => $this->_membershipStatusID,
     ];
-    $ids = [];
-    CRM_Member_BAO_Membership::create($params, $ids);
+
+    CRM_Member_BAO_Membership::create($params);
 
     $membershipId2 = $this->assertDBNotNull('CRM_Member_BAO_Membership', 'source123', 'id',
       'source', 'Database check for created membership.'
@@ -237,8 +234,8 @@ class CRM_Member_BAO_MembershipTest extends CiviUnitTestCase {
       'is_override' => 1,
       'status_id' => $this->_membershipStatusID,
     ];
-    $ids = [];
-    CRM_Member_BAO_Membership::create($params, $ids);
+
+    CRM_Member_BAO_Membership::create($params);
 
     $membershipId1 = $this->assertDBNotNull('CRM_Member_BAO_Membership', $contactId, 'id',
       'contact_id', 'Database check for created membership.'
@@ -259,8 +256,8 @@ class CRM_Member_BAO_MembershipTest extends CiviUnitTestCase {
       'is_override' => 1,
       'status_id' => $this->_membershipStatusID,
     ];
-    $ids = [];
-    CRM_Member_BAO_Membership::create($params, $ids);
+
+    CRM_Member_BAO_Membership::create($params);
 
     $membershipId2 = $this->assertDBNotNull('CRM_Member_BAO_Membership', 'PaySource', 'id',
       'source', 'Database check for created membership.'
@@ -410,8 +407,8 @@ class CRM_Member_BAO_MembershipTest extends CiviUnitTestCase {
       'is_override' => 1,
       'status_id' => $this->_membershipStatusID,
     ];
-    $ids = [];
-    $membership = CRM_Member_BAO_Membership::create($params, $ids);
+
+    $membership = CRM_Member_BAO_Membership::create($params);
     $membershipId = $this->assertDBNotNull('CRM_Member_BAO_Membership', $contactId, 'id',
       'contact_id', 'Database check for created membership.'
     );
@@ -480,8 +477,7 @@ class CRM_Member_BAO_MembershipTest extends CiviUnitTestCase {
       'status_id' => $statusId,
     ];
 
-    $ids = [];
-    $membership = CRM_Member_BAO_Membership::create($params, $ids);
+    $membership = CRM_Member_BAO_Membership::create($params);
 
     $membershipId = $this->assertDBNotNull('CRM_Member_BAO_Membership', $contactId, 'id',
       'contact_id', 'Database check for created membership.'
@@ -551,8 +547,8 @@ class CRM_Member_BAO_MembershipTest extends CiviUnitTestCase {
       'status_override_end_date' => date('Ymd', strtotime('-1 day')),
       'status_id' => $this->_membershipStatusID,
     ];
-    $ids = [];
-    $createdMembership = CRM_Member_BAO_Membership::create($params, $ids);
+
+    $createdMembership = CRM_Member_BAO_Membership::create($params);
 
     CRM_Member_BAO_Membership::updateAllMembershipStatus();
 
@@ -579,8 +575,8 @@ class CRM_Member_BAO_MembershipTest extends CiviUnitTestCase {
       'status_override_end_date' => date('Ymd', time()),
       'status_id' => $this->_membershipStatusID,
     ];
-    $ids = [];
-    $createdMembership = CRM_Member_BAO_Membership::create($params, $ids);
+
+    $createdMembership = CRM_Member_BAO_Membership::create($params);
 
     CRM_Member_BAO_Membership::updateAllMembershipStatus();
 
@@ -606,8 +602,8 @@ class CRM_Member_BAO_MembershipTest extends CiviUnitTestCase {
       'is_override' => 1,
       'status_id' => $this->_membershipStatusID,
     ];
-    $ids = [];
-    $createdMembership = CRM_Member_BAO_Membership::create($params, $ids);
+
+    $createdMembership = CRM_Member_BAO_Membership::create($params);
 
     CRM_Member_BAO_Membership::updateAllMembershipStatus();
 
@@ -821,8 +817,8 @@ class CRM_Member_BAO_MembershipTest extends CiviUnitTestCase {
       'is_override' => 1,
       'status_id' => $this->_membershipStatusID,
     ];
-    $ids = [];
-    CRM_Member_BAO_Membership::create($params, $ids);
+
+    CRM_Member_BAO_Membership::create($params);
 
     $membershipId = $this->assertDBNotNull('CRM_Member_BAO_Membership', $contactId, 'id',
       'contact_id', 'Database check for created membership.'
index ab848b86512c323264c06dd2dc39412ced58f94d..45f9178dbf1a157d520275fe4004aab5fd6eeda5 100644 (file)
@@ -308,8 +308,8 @@ class CRM_Member_BAO_MembershipTypeTest extends CiviUnitTestCase {
       'is_override' => 1,
       'status_id' => $this->_membershipStatusID,
     ];
-    $ids = [];
-    $membership = CRM_Member_BAO_Membership::create($params, $ids);
+
+    $membership = CRM_Member_BAO_Membership::create($params);
 
     $membershipRenewDates = CRM_Member_BAO_MembershipType::getRenewalDatesForMembershipType($membership->id);
 
index 2cb970ff0d53a1a92e2961abd413352365541fec..5d0bc095107fee43b861af96b90c9debf7a43769 100644 (file)
@@ -1169,6 +1169,8 @@ class api_v3_MembershipTest extends CiviUnitTestCase {
 
   /**
    * CRM-18503 - Test membership join date is correctly set for fixed memberships.
+   *
+   * @throws \CRM_Core_Exception
    */
   public function testMembershipJoinDateFixed() {
     $memStatus = CRM_Member_PseudoConstant::membershipStatus();
@@ -1185,9 +1187,7 @@ class api_v3_MembershipTest extends CiviUnitTestCase {
       'skipStatusCal' => 1,
       'is_for_organization' => 1,
     ];
-    // @todo stop passing empty $ids
-    $ids = [];
-    $membership = CRM_Member_BAO_Membership::create($params, $ids);
+    $membership = CRM_Member_BAO_Membership::create($params);
 
     // Update membership to 'Completed' and check the dates.
     $memParams = [