Skip to content

Commit

Permalink
Merge pull request #16825 from eileenmcnaughton/del_test
Browse files Browse the repository at this point in the history
[NFC] Use helper / api to delete contacts in tests
  • Loading branch information
colemanw authored Mar 17, 2020
2 parents 6ae069e + c6a3c74 commit 93110f1
Show file tree
Hide file tree
Showing 4 changed files with 15 additions and 15 deletions.
2 changes: 1 addition & 1 deletion tests/phpunit/CRM/Contact/BAO/ContactTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -668,7 +668,7 @@ public function testDeleteContact() {
$contactId = $contact->id;

//delete contact permanently.
CRM_Contact_BAO_Contact::deleteContact($contactId, FALSE, TRUE);
$this->contactDelete($contactId);

//Now check DB for location elements.
//Now check DB for Address
Expand Down
20 changes: 10 additions & 10 deletions tests/phpunit/CRM/Contact/BAO/ContactType/ContactTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,7 @@ public function testCreateContact() {
}
$this->assertEquals($contact->first_name, 'Anne');
$this->assertEquals($contact->contact_type, 'Individual');
CRM_Contact_BAO_Contact::deleteContact($contact->id);
$this->contactDelete($contact->id);

//check for Type:Organization
$params = [
Expand All @@ -91,7 +91,7 @@ public function testCreateContact() {
}
$this->assertEquals($contact->organization_name, 'Compumentor');
$this->assertEquals($contact->contact_type, 'Organization');
CRM_Contact_BAO_Contact::deleteContact($contact->id);
$this->contactDelete($contact->id);

//check for Type:Household
$params = [
Expand All @@ -105,7 +105,7 @@ public function testCreateContact() {
}
$this->assertEquals($contact->household_name, 'John Does home');
$this->assertEquals($contact->contact_type, 'Household');
CRM_Contact_BAO_Contact::deleteContact($contact->id);
$this->contactDelete($contact->id);

//check for Type:Individual, Subtype:Student
$params = [
Expand All @@ -122,7 +122,7 @@ public function testCreateContact() {
$this->assertEquals($contact->first_name, 'Bill');
$this->assertEquals($contact->contact_type, 'Individual');
$this->assertEquals(str_replace(CRM_Core_DAO::VALUE_SEPARATOR, '', $contact->contact_sub_type), $this->student);
CRM_Contact_BAO_Contact::deleteContact($contact->id);
$this->contactDelete($contact->id);

//check for Type:Organization, Subtype:Sponsor
$params = [
Expand All @@ -138,7 +138,7 @@ public function testCreateContact() {
$this->assertEquals($contact->organization_name, 'Conservation Corp');
$this->assertEquals($contact->contact_type, 'Organization');
$this->assertEquals(str_replace(CRM_Core_DAO::VALUE_SEPARATOR, '', $contact->contact_sub_type), $this->sponsor);
CRM_Contact_BAO_Contact::deleteContact($contact->id);
$this->contactDelete($contact->id);
}

/**
Expand Down Expand Up @@ -170,7 +170,7 @@ public function testUpdateContactNoSubtypeToValid() {
$this->assertEquals($updatedContact->id, $contact->id);
$this->assertEquals($updatedContact->contact_type, 'Individual');
$this->assertEquals(str_replace(CRM_Core_DAO::VALUE_SEPARATOR, '', $updatedContact->contact_sub_type), $this->student);
CRM_Contact_BAO_Contact::deleteContact($contact->id);
$this->contactDelete($contact->id);

$params = [
'organization_name' => 'Compumentor',
Expand All @@ -195,7 +195,7 @@ public function testUpdateContactNoSubtypeToValid() {
$this->assertEquals($updatedContact->id, $contact->id);
$this->assertEquals($updatedContact->contact_type, 'Organization');
$this->assertEquals(str_replace(CRM_Core_DAO::VALUE_SEPARATOR, '', $updatedContact->contact_sub_type), $this->sponsor);
CRM_Contact_BAO_Contact::deleteContact($contact->id);
$this->contactDelete($contact->id);
}

/**
Expand Down Expand Up @@ -228,7 +228,7 @@ public function testUpdateContactSubtype() {
$this->assertEquals($updatedContact->id, $contact->id);
$this->assertEquals($updatedContact->contact_type, 'Individual');
$this->assertEquals(str_replace(CRM_Core_DAO::VALUE_SEPARATOR, '', $updatedContact->contact_sub_type), $this->parent);
CRM_Contact_BAO_Contact::deleteContact($contact->id);
$this->contactDelete($contact->id);

$params = [
'organization_name' => 'Compumentor',
Expand All @@ -255,7 +255,7 @@ public function testUpdateContactSubtype() {
$this->assertEquals($updatedContact->id, $contact->id);
$this->assertEquals($updatedContact->contact_type, 'Organization');
$this->assertEquals(str_replace(CRM_Core_DAO::VALUE_SEPARATOR, '', $updatedContact->contact_sub_type), $this->team);
CRM_Contact_BAO_Contact::deleteContact($contact->id);
$this->contactDelete($contact->id);

$params = [
'first_name' => 'Anne',
Expand Down Expand Up @@ -283,7 +283,7 @@ public function testUpdateContactSubtype() {
$this->assertEquals($updatedContact->id, $contact->id);
$this->assertEquals($updatedContact->contact_type, 'Individual');
$this->assertEquals($updatedContact->contact_sub_type, 'null');
CRM_Contact_BAO_Contact::deleteContact($contact->id);
$this->contactDelete($contact->id);
}

/**
Expand Down
6 changes: 3 additions & 3 deletions tests/phpunit/CRM/Contact/Import/Parser/ContactTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -99,13 +99,13 @@ public function testImportParserWtihEmployeeOfRelationship() {
/**
* Test that import parser will not fail when same external_identifier found of deleted contact.
*
* @throws \Exception
* @throws \CRM_Core_Exception
*/
public function testImportParserWtihDeletedContactExternalIdentifier() {
$contactId = $this->individualCreate([
"external_identifier" => "ext-1",
'external_identifier' => 'ext-1',
]);
CRM_Contact_BAO_Contact::deleteContact($contactId);
$this->callAPISuccess('Contact', 'delete', ['id' => $contactId]);
list($originalValues, $result) = $this->setUpBaseContact([
'external_identifier' => 'ext-1',
]);
Expand Down
2 changes: 1 addition & 1 deletion tests/phpunit/CRM/Core/DAOTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -248,7 +248,7 @@ public function testFindById() {
$contact = CRM_Contact_BAO_Contact::findById($existing_contact->id);
$this->assertEquals($existing_contact->id, $contact->id);
$deleted_contact_id = $existing_contact->id;
CRM_Contact_BAO_Contact::deleteContact($contact->id, FALSE, TRUE);
$this->contactDelete($contact->id);
$exception_thrown = FALSE;
try {
$deleted_contact = CRM_Contact_BAO_Contact::findById($deleted_contact_id);
Expand Down

0 comments on commit 93110f1

Please sign in to comment.