From 6775d52158d646cfdd3ba7805be139333b0fbbbd Mon Sep 17 00:00:00 2001 From: Eileen McNaughton Date: Tue, 28 Jun 2022 17:35:33 +1200 Subject: [PATCH] Add second currency example --- .../Contribution/BasicContribution.php | 27 ++++++++++++++----- 1 file changed, 20 insertions(+), 7 deletions(-) diff --git a/CRM/Contribute/WorkflowMessage/Contribution/BasicContribution.php b/CRM/Contribute/WorkflowMessage/Contribution/BasicContribution.php index 954385ac82..bce3c8ca0f 100644 --- a/CRM/Contribute/WorkflowMessage/Contribution/BasicContribution.php +++ b/CRM/Contribute/WorkflowMessage/Contribution/BasicContribution.php @@ -19,11 +19,18 @@ class CRM_Contribute_WorkflowMessage_Contribution_BasicContribution extends Work $workflows = ['contribution_online_receipt', 'contribution_offline_receipt', 'contribution_invoice_receipt']; foreach ($workflows as $workflow) { yield [ - 'name' => 'workflow/' . $workflow . '/' . $this->getExampleName(), - 'title' => ts('Completed Contribution'), + 'name' => 'workflow/' . $workflow . '/basic_eur', + 'title' => ts('Completed Contribution') . ' : ' . 'CAD', 'tags' => ['preview'], 'workflow' => $workflow, ]; + yield [ + 'name' => 'workflow/' . $workflow . '/' . 'basic_cad', + 'title' => ts('Completed Contribution') . ' : ' . 'CAD', + 'tags' => ['preview'], + 'workflow' => 'contribution_offline_receipt', + 'currency' => 'CAD', + ]; } } @@ -33,14 +40,12 @@ class CRM_Contribute_WorkflowMessage_Contribution_BasicContribution extends Work * @param array $example * * @throws \API_Exception - * @throws \CRM_Core_Exception - * @throws \Civi\API\Exception\UnauthorizedException */ public function build(array &$example): void { $workFlow = WorkflowMessage::get(TRUE)->addWhere('name', '=', $example['workflow'])->execute()->first(); $this->setWorkflowName($workFlow['name']); $messageTemplate = new $workFlow['class'](); - $this->addExampleData($messageTemplate); + $this->addExampleData($messageTemplate, $example); $example['data'] = $this->toArray($messageTemplate); } @@ -48,16 +53,24 @@ class CRM_Contribute_WorkflowMessage_Contribution_BasicContribution extends Work * Add relevant example data. * * @param \CRM_Contribute_WorkflowMessage_ContributionOfflineReceipt|\CRM_Contribute_WorkflowMessage_ContributionOnlineReceipt|\CRM_Contribute_WorkflowMessage_ContributionInvoiceReceipt $messageTemplate + * @param array $example * + * @throws \API_Exception * @throws \CRM_Core_Exception + * @throws \CiviCRM_API3_Exception + * @throws \Civi\API\Exception\UnauthorizedException */ - private function addExampleData(GenericWorkflowMessage $messageTemplate): void { + private function addExampleData(GenericWorkflowMessage $messageTemplate, $example): void { $messageTemplate->setContact(\Civi\Test::example('entity/Contact/Barb')); - $messageTemplate->setContribution(\Civi\Test::example('entity/Contribution/Euro5990/completed')); + $contribution = \Civi\Test::example('entity/Contribution/Euro5990/completed'); + if (isset($example['currency'])) { + $contribution['currency'] = $example['currency']; + } $mockOrder = new CRM_Financial_BAO_Order(); $mockOrder->setTemplateContributionID(50); $mockOrder->setPriceSetToDefault('contribution'); $messageTemplate->setOrder($mockOrder); + $messageTemplate->setContribution($contribution); } } -- 2.25.1