Skip to content

Commit

Permalink
[REF] Stop returning unused variables
Browse files Browse the repository at this point in the history
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
  • Loading branch information
eileenmcnaughton committed Jan 8, 2022
1 parent 1968006 commit c64f77c
Show file tree
Hide file tree
Showing 3 changed files with 5 additions and 85 deletions.
2 changes: 1 addition & 1 deletion CRM/Contact/BAO/Relationship.php
Original file line number Diff line number Diff line change
Expand Up @@ -222,7 +222,7 @@ public static function legacyCreateMultiple(&$params, $ids = []) {
self::addRecent($params, $relationship);
}

return [$valid, $invalid, $duplicate, $saved, $relationshipIds, $relationships];
return [$valid, $duplicate];
}

/**
Expand Down
2 changes: 1 addition & 1 deletion CRM/Contact/Import/Parser/Contact.php
Original file line number Diff line number Diff line change
Expand Up @@ -893,7 +893,7 @@ public function import($onDuplicate, &$values, $doGeocodeAddress = FALSE) {
'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;
Expand Down
86 changes: 3 additions & 83 deletions tests/phpunit/CRM/Contact/BAO/ContactType/RelationshipTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -146,82 +146,6 @@ public function testRelationshipTypeAddStudentSponcor() {
$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
Expand All @@ -242,11 +166,9 @@ public function testRelationshipCreateWithinSameType() {
'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);
}

/**
Expand All @@ -269,10 +191,9 @@ public function testRelCreateWithinDiffTypeSponsorIndivi() {
'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);
}

Expand All @@ -293,10 +214,9 @@ public function testRelCreateWithinDiffTypeStudentSponsor() {
'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);
}

Expand Down

0 comments on commit c64f77c

Please sign in to comment.