Skip to content

Commit

Permalink
Core now creates ufmatches on install, so trying to create it in test…
Browse files Browse the repository at this point in the history
… setup leads to fails (#1004)

* no longer need to create ufmatch

* don't assume contact id is always 2
  • Loading branch information
demeritcowboy authored Sep 9, 2024
1 parent 408a365 commit 3146aae
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 9 deletions.
5 changes: 3 additions & 2 deletions tests/src/FunctionalJavascript/MembershipSubmissionTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -122,11 +122,12 @@ public function testSubmitWebform() {

$this->saveCiviCRMSettings();

$adminUserCid = $this->getUFMatchRecord($this->adminUser->id())['contact_id'];
// Create two memberships with the same status with the first membership
// having an end date after the second membership's end date.
$this->utils->wf_civicrm_api('membership', 'create', [
'membership_type_id' => 'Basic',
'contact_id' => 2,
'contact_id' => $adminUserCid,
'join_date' => '08/10/21',
'start_date' => '08/10/21',
'end_date' => '08/10/22',
Expand All @@ -136,7 +137,7 @@ public function testSubmitWebform() {

$this->utils->wf_civicrm_api('membership', 'create', [
'membership_type_id' => 'Basic',
'contact_id' => 2,
'contact_id' => $adminUserCid,
'join_date' => '01/01/21',
'start_date' => '01/01/21',
'end_date' => '01/01/22',
Expand Down
19 changes: 12 additions & 7 deletions tests/src/FunctionalJavascript/WebformCivicrmTestBase.php
Original file line number Diff line number Diff line change
Expand Up @@ -98,13 +98,18 @@ protected function setUp(): void {
'id' => 'civicrm_webform_test',
'title' => 'CiviCRM Webform Test.' . $CiviCRM_version,
]);
$this->rootUserCid = $this->createIndividual()['id'];
// Create CiviCRM contact for rootUser.
$this->utils->wf_civicrm_api('UFMatch', 'create', [
'uf_id' => $this->rootUser->id(),
'uf_name' => $this->rootUser->getAccountName(),
'contact_id' => $this->rootUserCid,
]);
if (version_compare(\CRM_Core_BAO_Domain::version(), '5.79.alpha1', '<')) {
$this->rootUserCid = $this->createIndividual()['id'];
// Create CiviCRM contact for rootUser.
$this->utils->wf_civicrm_api('UFMatch', 'create', [
'uf_id' => $this->rootUser->id(),
'uf_name' => $this->rootUser->getAccountName(),
'contact_id' => $this->rootUserCid,
]);
}
else {
$this->rootUserCid = $this->getUFMatchRecord($this->rootUser->id())['contact_id'];
}
}

protected function tearDown(): void {
Expand Down

0 comments on commit 3146aae

Please sign in to comment.