Skip to content

Commit

Permalink
Merge pull request #21661 from eileenmcnaughton/cleanup
Browse files Browse the repository at this point in the history
Basic IDE cleanup on test class
  • Loading branch information
colemanw authored Sep 29, 2021
2 parents f0f954e + ebb4e06 commit f37e22a
Showing 1 changed file with 11 additions and 7 deletions.
18 changes: 11 additions & 7 deletions tests/events/hook_civicrm_alterMailParams.evch.php
Original file line number Diff line number Diff line change
@@ -1,5 +1,9 @@
<?php
return new class() extends \Civi\Test\EventCheck implements \Civi\Test\HookInterface {

use Civi\Test\EventCheck;
use Civi\Test\HookInterface;

return new class() extends EventCheck implements HookInterface {

private $paramSpecs = [

Expand Down Expand Up @@ -85,7 +89,7 @@
'disableSmarty' => ['type' => 'bool|int', 'for' => 'messageTemplate'],
];

public function isSupported($test) {
public function isSupported($test): bool {
// MailTest does intentionally breaky things to provoke+ensure decent error-handling.
//So we will not enforce generic rules on it.
return !($test instanceof CRM_Utils_MailTest);
Expand All @@ -96,8 +100,8 @@ public function isSupported($test) {
*
* @see \CRM_Utils_Hook::alterMailParams()
*/
public function hook_civicrm_alterMailParams(&$params, $context = NULL) {
$msg = "Non-conformant hook_civicrm_alterMailParams(..., $context)";
public function hook_civicrm_alterMailParams(&$params, $context = NULL): void {
$msg = 'Non-conforming hook_civicrm_alterMailParams(..., $context)';
$dump = print_r($params, 1);

$this->assertRegExp('/^(messageTemplate|civimail|singleEmail|flexmailer)$/',
Expand Down Expand Up @@ -129,7 +133,7 @@ public function hook_civicrm_alterMailParams(&$params, $context = NULL) {
}

if ($context === 'messageTemplate') {
$this->assertTrue(!empty($params['workflow']), "$msg: Message templates must always specify a symbolic name of the step/task\n$dump");
$this->assertNotEmpty($params['workflow'], "$msg: Message templates must always specify a symbolic name of the step/task\n$dump");
if (isset($params['valueName'])) {
// This doesn't require that valueName be supplied - but if it is supplied, it must match the workflow name.
$this->assertEquals($params['workflow'], $params['valueName'], "$msg: If given, workflow and valueName must match\n$dump");
Expand All @@ -145,8 +149,8 @@ public function hook_civicrm_alterMailParams(&$params, $context = NULL) {
}

if (isset($params['groupName']) && $params['groupName'] === 'Scheduled Reminder Sender') {
$this->assertTrue(!empty($params['entity']), "$msg: Scheduled reminders should have entity\n$dump");
$this->assertTrue(!empty($params['entity_id']), "$msg: Scheduled reminders should have entity_id\n$dump");
$this->assertNotEmpty($params['entity'], "$msg: Scheduled reminders should have entity\n$dump");
$this->assertNotEmpty($params['entity_id'], "$msg: Scheduled reminders should have entity_id\n$dump");
}
}

Expand Down

0 comments on commit f37e22a

Please sign in to comment.