From 3d1f6d1c0e5e8b30695d9b64df341f8bf0144ce1 Mon Sep 17 00:00:00 2001 From: Tim Otten Date: Tue, 28 Sep 2021 14:55:44 -0700 Subject: [PATCH] (REF) hook_civicrm_alterMailParams.evch.php - Soften 'type' check This changes some of the plumbing in how it interprets 'paramSpecs' - but doesn't change anything substantive. Before: You must specify a 'type' constraint for every param. After: You may omit the 'type' constraint for some params. Before: If you specify a nullable string with a regex, then null-values will fail. After: If you specify a nullable string with a regex, then null-values will pass. --- tests/events/hook_civicrm_alterMailParams.evch.php | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/tests/events/hook_civicrm_alterMailParams.evch.php b/tests/events/hook_civicrm_alterMailParams.evch.php index 0a1e0690d3..d7ae1bf5b9 100644 --- a/tests/events/hook_civicrm_alterMailParams.evch.php +++ b/tests/events/hook_civicrm_alterMailParams.evch.php @@ -115,8 +115,10 @@ return new class() extends \Civi\Test\EventCheck implements \Civi\Test\HookInter $this->assertEquals([], $unknownKeys, "$msg: Unrecognized keys: " . implode(', ', $unknownKeys) . "\n$dump"); foreach ($params as $key => $value) { - $this->assertType($paramSpecs[$key]['type'], $value, "$msg: Bad data-type found in param ($key)\n$dump"); - if (isset($paramSpecs[$key]['regex'])) { + if (isset($paramSpecs[$key]['type'])) { + $this->assertType($paramSpecs[$key]['type'], $value, "$msg: Bad data-type found in param ($key)\n$dump"); + } + if (isset($paramSpecs[$key]['regex']) && $value !== NULL) { $this->assertRegExp($paramSpecs[$key]['regex'], $value, "Parameter [$key => $value] should match regex ({$paramSpecs[$key]['regex']})"); } } -- 2.25.1