From 98e528a20637e880863371a1277f13a887e37eb5 Mon Sep 17 00:00:00 2001 From: Eileen McNaughton Date: Thu, 10 Nov 2022 20:02:19 +1300 Subject: [PATCH] dev/core#3981 Fix Examples to use 0 rather than a possibly-real contact_id Overview ================================================== dev/core#3981 Fix Examples to use 0 rather than a possibly-real contact_id https://lab.civicrm.org/dev/core/-/issues/3981 Before ============================================== When using the Message Admin UI and trying out tokens those that are not explicitly defined in the sample data are fetched from the database from the contact whose id has been arbitrarily used. After ======================================================================= The contact_id is set to 0. As a result nothing is retrievable from the databse. Technical Details ======================================================================= I suspect this was not possible when the example was first written (the token code has matured a bit) & a stand in number seemed intuitive - but I think that is arguable even when there are no negative side effects (for example if a url were in the letter then linking to a random contact from it is kinda confusing) - but really loses it's potency as an argument when there ARE negative side effects Comments ============================================================================ I'm pretty sure there are some tests I need to adjust for this.... --- Civi/Test/ExampleData/Contact/Alex.php | 6 ++++-- Civi/Test/ExampleData/Contact/Barb.php | 6 ++++-- Civi/Test/ExampleData/Contact/TheDailyBugle.php | 2 +- 3 files changed, 9 insertions(+), 5 deletions(-) diff --git a/Civi/Test/ExampleData/Contact/Alex.php b/Civi/Test/ExampleData/Contact/Alex.php index b6f00fdf16aa..9b4e155db0e6 100644 --- a/Civi/Test/ExampleData/Contact/Alex.php +++ b/Civi/Test/ExampleData/Contact/Alex.php @@ -2,7 +2,9 @@ namespace Civi\Test\ExampleData\Contact; -class Alex extends \Civi\Test\EntityExample { +use Civi\Test\EntityExample; + +class Alex extends EntityExample { public function getExamples(): iterable { yield [ @@ -12,7 +14,7 @@ public function getExamples(): iterable { public function build(array &$example): void { $example['data'] = [ - 'id' => '100', + 'id' => 0, 'first_name' => 'Alex', 'middle_name' => '', 'last_name' => 'D\u00edaz', diff --git a/Civi/Test/ExampleData/Contact/Barb.php b/Civi/Test/ExampleData/Contact/Barb.php index 015b6a0e9d00..6127f89700e8 100644 --- a/Civi/Test/ExampleData/Contact/Barb.php +++ b/Civi/Test/ExampleData/Contact/Barb.php @@ -2,7 +2,9 @@ namespace Civi\Test\ExampleData\Contact; -class Barb extends \Civi\Test\EntityExample { +use Civi\Test\EntityExample; + +class Barb extends EntityExample { public function getExamples(): iterable { yield [ @@ -12,7 +14,7 @@ public function getExamples(): iterable { public function build(array &$example): void { $example['data'] = [ - 'contact_id' => '100', + 'contact_id' => 0, 'contact_type' => 'Individual', 'contact_sub_type' => NULL, 'sort_name' => 'Johnson, Barbara', diff --git a/Civi/Test/ExampleData/Contact/TheDailyBugle.php b/Civi/Test/ExampleData/Contact/TheDailyBugle.php index a4604c2f49fe..e825b7507912 100644 --- a/Civi/Test/ExampleData/Contact/TheDailyBugle.php +++ b/Civi/Test/ExampleData/Contact/TheDailyBugle.php @@ -14,7 +14,7 @@ public function getExamples(): iterable { public function build(array &$example): void { $example['data'] = [ - 'contact_id' => 102, + 'contact_id' => 0, 'contact_type' => 'Organization', 'organization_name' => 'The Daily Bugle', 'sort_name' => 'Daily Bugle',