[REF] Stop returning unused variables
authorEileen McNaughton <emcnaughton@wikimedia.org>
Fri, 7 Jan 2022 02:06:19 +0000 (15:06 +1300)
committerEileen McNaughton <emcnaughton@wikimedia.org>
Sat, 8 Jan 2022 02:07:29 +0000 (15:07 +1300)
Only 2 code places call this function (one an unsupported call outside core but in universe & the other in Parser_Contact)
and only the latter uses ANY of the return variables - this fixes the function to stop
returning those that are never used  - this stops them from returning them

CRM/Contact/BAO/Relationship.php
CRM/Contact/Import/Parser/Contact.php
tests/phpunit/CRM/Contact/BAO/ContactType/RelationshipTest.php

index 2d623c5daebed29bece66a9ea54b427d8c488daf..487576581f4b315cc12504888f0386de13e02d56 100644 (file)
@@ -222,7 +222,7 @@ class CRM_Contact_BAO_Relationship extends CRM_Contact_DAO_Relationship {
       self::addRecent($params, $relationship);
     }
 
-    return [$valid, $invalid, $duplicate, $saved, $relationshipIds, $relationships];
+    return [$valid, $duplicate];
   }
 
   /**
index 36d581f43e061ed8f7ce026e3f4c6c5ec8bacf80..8399c5fb401d123037f758c9cc49ab5e2ecd3c5a 100644 (file)
@@ -893,7 +893,7 @@ class CRM_Contact_Import_Parser_Contact extends CRM_Contact_Import_Parser {
                 'contact' => $primaryContactId,
               ];
 
-              [$valid, $invalid, $duplicate, $saved, $relationshipIds] = CRM_Contact_BAO_Relationship::legacyCreateMultiple($relationParams, $relationIds);
+              [$valid, $duplicate] = CRM_Contact_BAO_Relationship::legacyCreateMultiple($relationParams, $relationIds);
 
               if ($valid || $duplicate) {
                 $relationIds['contactTarget'] = $relContactId;
index c2ff108942d2e3bd24a8d22e7b30ca29215c9946..7280901e470d2ea7067a16c48a3e5326b43959ad 100644 (file)
@@ -146,82 +146,6 @@ DELETE FROM civicrm_contact_type
     $this->relationshipTypeDelete($result->id);
   }
 
-  /**
-   * Methods create relationshipe within same contact type with invalid Relationships.
-   */
-  public function testRelationshipCreateInvalidWithinSameType() {
-    //check for Individual to Parent
-    $relTypeParams = [
-      'name_a_b' => 'indivToparent',
-      'name_b_a' => 'parentToindiv',
-      'contact_type_a' => 'Individual',
-      'contact_type_b' => 'Individual',
-      'contact_sub_type_b' => $this->parent,
-    ];
-    $relType = CRM_Contact_BAO_RelationshipType::add($relTypeParams);
-    $params = [
-      'relationship_type_id' => $relType->id . '_a_b',
-      'contact_check' => [$this->indivi_student => 1],
-    ];
-    $ids = ['contact' => $this->individual];
-
-    list($valid, $invalid, $duplicate, $saved, $relationshipIds) = CRM_Contact_BAO_Relationship::legacyCreateMultiple($params, $ids);
-
-    $this->assertEquals($invalid, 1);
-    $this->assertEquals(empty($relationshipIds), TRUE);
-    $this->relationshipTypeDelete($relType->id);
-  }
-
-  /**
-   * Methods create relationshipe within diff contact type with invalid Relationships.
-   */
-  public function testRelCreateInvalidWithinDiffTypeSpocorIndivi() {
-    //check for Sponcer to Individual
-    $relTypeParams = [
-      'name_a_b' => 'SponsorToIndiv',
-      'name_b_a' => 'IndivToSponsor',
-      'contact_type_a' => 'Organization',
-      'contact_sub_type_a' => $this->sponsor,
-      'contact_type_b' => 'Individual',
-    ];
-    $relType = CRM_Contact_BAO_RelationshipType::add($relTypeParams);
-    $params = [
-      'relationship_type_id' => $relType->id . '_a_b',
-      'contact_check' => [$this->individual => 1],
-    ];
-    $ids = ['contact' => $this->indivi_parent];
-
-    list($valid, $invalid, $duplicate, $saved, $relationshipIds) = CRM_Contact_BAO_Relationship::legacyCreateMultiple($params, $ids);
-
-    $this->assertEquals($invalid, 1);
-    $this->assertEquals(empty($relationshipIds), TRUE);
-    $this->relationshipTypeDelete($relType->id);
-  }
-
-  public function testRelCreateInvalidWithinDiffTypeStudentSponcor() {
-    //check for Student to Sponcer
-    $relTypeParams = [
-      'name_a_b' => 'StudentToSponser',
-      'name_b_a' => 'SponsorToStudent',
-      'contact_type_a' => 'Individual',
-      'contact_sub_type_a' => $this->student,
-      'contact_type_b' => 'Organization',
-      'contact_sub_type_b' => 'Sponser',
-    ];
-    $relType = CRM_Contact_BAO_RelationshipType::add($relTypeParams);
-    $params = [
-      'relationship_type_id' => $relType->id . '_a_b',
-      'contact_check' => [$this->individual => 1],
-    ];
-    $ids = ['contact' => $this->indivi_parent];
-
-    list($valid, $invalid, $duplicate, $saved, $relationshipIds) = CRM_Contact_BAO_Relationship::legacyCreateMultiple($params, $ids);
-
-    $this->assertEquals($invalid, 1);
-    $this->assertEquals(empty($relationshipIds), TRUE);
-    $this->relationshipTypeDelete($relType->id);
-  }
-
   /**
    * Methods create relationshipe within same contact type with valid data.
    * success expected
@@ -242,11 +166,9 @@ DELETE FROM civicrm_contact_type
       'contact_check' => [$this->indivi_parent => $this->indivi_parent],
     ];
     $ids = ['contact' => $this->individual];
-    list($valid, $invalid, $duplicate, $saved, $relationshipIds) = CRM_Contact_BAO_Relationship::legacyCreateMultiple($params, $ids);
+    list($valid) = CRM_Contact_BAO_Relationship::legacyCreateMultiple($params, $ids);
 
     $this->assertEquals($valid, 1);
-    $this->assertEquals(empty($relationshipIds), FALSE);
-    $this->relationshipTypeDelete($relType->id);
   }
 
   /**
@@ -269,10 +191,9 @@ DELETE FROM civicrm_contact_type
       'contact_check' => [$this->indivi_student => 1],
     ];
     $ids = ['contact' => $this->organization_sponsor];
-    list($valid, $invalid, $duplicate, $saved, $relationshipIds) = CRM_Contact_BAO_Relationship::legacyCreateMultiple($params, $ids);
+    list($valid) = CRM_Contact_BAO_Relationship::legacyCreateMultiple($params, $ids);
 
     $this->assertEquals($valid, 1);
-    $this->assertEquals(empty($relationshipIds), FALSE);
     $this->relationshipTypeDelete($relType->id);
   }
 
@@ -293,10 +214,9 @@ DELETE FROM civicrm_contact_type
       'contact_check' => [$this->organization_sponsor => 1],
     ];
     $ids = ['contact' => $this->indivi_student];
-    list($valid, $invalid, $duplicate, $saved, $relationshipIds) = CRM_Contact_BAO_Relationship::legacyCreateMultiple($params, $ids);
+    list($valid) = CRM_Contact_BAO_Relationship::legacyCreateMultiple($params, $ids);
 
     $this->assertEquals($valid, 1);
-    $this->assertEquals(empty($relationshipIds), FALSE);
     $this->relationshipTypeDelete($relType->id);
   }