Skip to content

Commit

Permalink
SnapshotUpgradeTest - Add support for pure-api4 entity
Browse files Browse the repository at this point in the history
  • Loading branch information
totten committed Sep 26, 2024
1 parent e91975d commit a88f3d9
Showing 1 changed file with 17 additions and 0 deletions.
17 changes: 17 additions & 0 deletions tests/e2e/SnapshotUpgradeTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@
* - 'qf': An extension with some QuickForm pages/forms.
* - 'entity3': An extension with an entity supporting APIv3.
* - 'entity34': An extension with an entity supporting APIv3 and APIv4.
* - 'entity4': An extension with an entity supporting APIv4.
* - 'kitchensink': An extension with a bunch of random things. (Varies based on the CIVIX_VERSION.)
* - 'svc': An extension with a service-object.
* - (NOTE: For a more detailed sketch of each scenario, see `tests/make-snapshots.sh`.)
Expand Down Expand Up @@ -143,6 +144,22 @@ public function checkSnapshot_entity34(): void {
$this->assertTrue(in_array('FK to Contact', $descriptions4), "$entity.contact_id should have APIv4 description. Actual metadata response was: ");
}

/**
* The "*-entity4.zip" snapshots include an entity ("MyEntityFour") with APIv4 support.
* This also appears in some kitchen-sink builds.
*/
public function checkSnapshot_entity4(): void {
$this->runsIf($this->isScenario('entity4') || $this->isKitchenSinkWith('xml/schema/CRM/Civixsnapshot/MyEntityFour.xml'));

$entity = 'MyEntityFour';

$getFields4 = PH::runOK("cv api4 $entity.getFields --out=json");
$parsed4 = json_decode($getFields4->getOutput(), TRUE);
$descriptions4 = array_column($parsed4, 'description');
$this->assertTrue(in_array("Unique $entity ID", $descriptions4), "$entity.id should have APIv4 description. Actual metadata response was: ");
$this->assertTrue(in_array('FK to Contact', $descriptions4), "$entity.contact_id should have APIv4 description. Actual metadata response was: ");
}

/**
* The "*-qf.zip" snapshots include a traditional page+form (eg "civicrm/my-page").
* This also appears in some kitchen-sink builds.
Expand Down

0 comments on commit a88f3d9

Please sign in to comment.