Skip to content

Commit

Permalink
Merge pull request #25342 from braders/dynamic-params-contact-type-test
Browse files Browse the repository at this point in the history
[REF][PHP8.2] Avoid dynamic properties in api_v3_ContactTypeTest
  • Loading branch information
seamuslee001 authored Jan 14, 2023
2 parents 4c0d9a7 + e265090 commit 1bfd2e8
Showing 1 changed file with 26 additions and 11 deletions.
37 changes: 26 additions & 11 deletions tests/phpunit/api/v3/ContactTypeTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,21 @@
class api_v3_ContactTypeTest extends CiviUnitTestCase {
protected $_apiversion;

/**
* @var string
*/
protected $subTypeIndividual;

/**
* @var string
*/
protected $subTypeOrganization;

/**
* @var string
*/
protected $subTypeHousehold;

public function setUp(): void {
parent::setUp();
$this->useTransaction(TRUE);
Expand All @@ -26,7 +41,7 @@ public function setUp(): void {
'parent_id' => 1,
'is_active' => 1,
];
$result = CRM_Contact_BAO_ContactType::add($params);
CRM_Contact_BAO_ContactType::add($params);
$this->subTypeIndividual = $params['name'];

$params = [
Expand All @@ -36,7 +51,7 @@ public function setUp(): void {
'parent_id' => 3,
'is_active' => 1,
];
$result = CRM_Contact_BAO_ContactType::add($params);
CRM_Contact_BAO_ContactType::add($params);
$this->subTypeOrganization = $params['name'];

$params = [
Expand All @@ -46,7 +61,7 @@ public function setUp(): void {
'parent_id' => 2,
'is_active' => 1,
];
$result = CRM_Contact_BAO_ContactType::add($params);
CRM_Contact_BAO_ContactType::add($params);
$this->subTypeHousehold = $params['name'];
}

Expand Down Expand Up @@ -111,15 +126,15 @@ public function testContactAddInvalidData($version) {
'contact_type' => 'Individual',
'contact_sub_type' => $this->subTypeHousehold,
];
$contact = $this->callAPIFailure('contact', 'create', $contactParams);
$this->callAPIFailure('contact', 'create', $contactParams);

// check for Type:Organization Subtype:sub_individual
$contactParams = [
'organization_name' => 'Compumentor',
'contact_type' => 'Organization',
'contact_sub_type' => $this->subTypeIndividual,
];
$contact = $this->callAPIFailure('contact', 'create', $contactParams);
$this->callAPIFailure('contact', 'create', $contactParams);
}

/**
Expand Down Expand Up @@ -214,7 +229,7 @@ public function testContactUpdateNoSubtypeInvalid($version) {
'contact_type' => 'Individual',
'contact_sub_type' => $this->subTypeHousehold,
];
$updateContact = $this->callAPIFailure('contact', 'create', $updateParams);
$this->callAPIFailure('contact', 'create', $updateParams);
$params = [
'contact_id' => $contact['id'],
];
Expand All @@ -233,7 +248,7 @@ public function testContactUpdateNoSubtypeInvalid($version) {
'contact_type' => 'Organization',
'contact_sub_type' => $this->subTypeIndividual,
];
$updateContact = $this->callAPIFailure('contact', 'create', $updateParams);
$this->callAPIFailure('contact', 'create', $updateParams);
$params = [
'contact_id' => $contact['id'],
];
Expand All @@ -256,7 +271,7 @@ public function testContactUpdateSubtypeValid($version) {
'parent_id' => 1,
'is_active' => 1,
];
$getSubtype = CRM_Contact_BAO_ContactType::add($params);
CRM_Contact_BAO_ContactType::add($params);
$subtype = $params['name'];

// check for Type:Individual subype:sub_individual
Expand Down Expand Up @@ -299,7 +314,7 @@ public function testContactUpdateSubtypeValid($version) {
'parent_id' => 3,
'is_active' => 1,
];
$getSubtype = CRM_Contact_BAO_ContactType::add($params);
CRM_Contact_BAO_ContactType::add($params);
$subtype = $params['name'];

// check for Type:Organization subype:sub_organization
Expand Down Expand Up @@ -357,7 +372,7 @@ public function testContactUpdateSubtypeInvalid($version) {
'contact_type' => 'Individual',
'contact_sub_type' => $this->subTypeHousehold,
];
$updateContact = $this->callAPIFailure('contact', 'create', $updateParams);
$this->callAPIFailure('contact', 'create', $updateParams);
$params = [
'contact_id' => $contact['id'],
];
Expand All @@ -376,7 +391,7 @@ public function testContactUpdateSubtypeInvalid($version) {
'contact_id' => $contact['id'],
'contact_sub_type' => $this->subTypeIndividual,
];
$updateContact = $this->callAPIFailure('contact', 'create', $updateParams);
$this->callAPIFailure('contact', 'create', $updateParams);
$params = [
'contact_id' => $contact['id'],
];
Expand Down

0 comments on commit 1bfd2e8

Please sign in to comment.