Skip to content

Commit

Permalink
Add snapshot with an example service
Browse files Browse the repository at this point in the history
  • Loading branch information
totten committed Dec 3, 2023
1 parent f92e4e5 commit 1ec7e2a
Show file tree
Hide file tree
Showing 3 changed files with 18 additions and 3 deletions.
10 changes: 7 additions & 3 deletions scripts/make-snapshots.sh
Original file line number Diff line number Diff line change
Expand Up @@ -22,13 +22,13 @@ while [ -n "$1" ]; do
--version) SNAPSHOT_VER="$1" ; shift ; ;;
--test|-t) RUN_TEST=1 ; ;;
--keep|-k) KEEP=1 ; ;;
empty|qf|entity3|entity34|kitchensink) SCENARIOS="$SCENARIOS $OPT" ; ;;
empty|qf|entity3|entity34|kitchensink|svc) SCENARIOS="$SCENARIOS $OPT" ; ;;
*) echo "Unrecognized option: $OPT" 1>&2 ; exit 1 ;;
esac
done

if [ -z "$SCENARIOS" ]; then
SCENARIOS="empty qf entity3 entity34 kitchensink"
SCENARIOS="empty qf entity3 entity34 kitchensink svc"
fi

################################################
Expand All @@ -47,7 +47,7 @@ function show_help() {
echo " --keep: Keep the temporary work folder"
echo
echo "Scenarios:"
echo " empty qf entity3 entity34 kitchensink"
echo " empty qf entity3 entity34 kitchensink svc"
echo
echo "Example:"
echo " CIVIX_WORKSPACE=\$CIVIBUILD_HOME/dmaster/web/sites/all/modules/civicrm/ext/civixtest bash $0 --src"
Expand Down Expand Up @@ -121,6 +121,10 @@ function build_snapshot() {
$CIVIX $VERBOSITY generate:theme extratheme
;;

svc)
$CIVIX $VERBOSITY generate:service some.thing --naming=Civi --no-interaction
;;

*)
echo "Error: unrecognized snapshot type $name" 1>&2
exit 1
Expand Down
11 changes: 11 additions & 0 deletions tests/e2e/SnapshotUpgradeTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@
* - 'entity3': An extension with an entity supporting APIv3.
* - 'entity34': An extension with an entity supporting APIv3 and 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`.)
*
* SnapshotUpgradeTest MUST run in an environment with `civibuild` and `cv`. It will use `civibuild restore`
Expand Down Expand Up @@ -165,4 +166,14 @@ public function checkSnapshot_qf(): void {
$this->assertRegExp(';The current time is;', $httpGet->getOutput());
}

public function checkSnapshot_svc(): void {
$this->runsIf($this->isScenario('svc') || $this->isKitchenSinkWith('Civi/Civixsnapshot/Some/Thing.php'));

$getServices = PH::runOK("cv service some.thing --out=json");
$parsed = json_decode($getServices->getOutput(), TRUE);
$this->assertEquals('some.thing', $parsed[0]['service']);
$this->assertEquals('Civi\\Civixsnapshot\\Some\\Thing', $parsed[0]['class']);
$this->assertTrue(preg_match(';tag.event_sub;', $parsed[0]['extras']));
}

}
Binary file not shown.

0 comments on commit 1ec7e2a

Please sign in to comment.