Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Ref] Extend email trait test, process more sanely #21553

Merged
merged 2 commits into from
Sep 21, 2021

Conversation

eileenmcnaughton
Copy link
Contributor

Overview

[Ref] Extend email trait test, process more sanely

Builds on #21540 which is already a bit of a crazy battle!

Before

Weird process retrieves email addresses from the submitted 'to' values in the buildForm

After

Moved to the postProcess - now testable

Technical Details

This is an artefact of the way the email tasks used to all pass $form to a static function - it would up 'doing stuff where it could' in buildForm not in a sane place. This now uses getSubmittedValues - the same could be extended to the other weird loading stuff later on

Comments

@civibot
Copy link

civibot bot commented Sep 20, 2021

(Standard links)

This extracts the code used to get the from values, moves the default setting
to the default and adds a test.

The goal is actually to add a test on the submit function
but it's proving to be challenging so this at least gets the
default setting tested.

Note that this code used to be on a static class, not a trait, and
some stuff is in weird places - in particular stuff that
should be in setDefaults and postProcess is happening on
preProcess. However, most
of the classes that override this
trait do not do much more than call the trait so that helps at
least
$to[] = $deceasedContactID . '::' . 'email@example.com';
/* @var CRM_Contact_Form_Task_Email $form*/
$form = $this->getFormObject('CRM_Contact_Form_Task_Email', [
'to' => implode(',', $to),
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is the key part of the change to this test - we are now passing 'to' as a submitted value rather than setting properties on the form (this is a good change)

@demeritcowboy
Copy link
Contributor

Seems to run ok. I vaguely remember a previous attempt to remove toContact and it caused some problem, but maybe that was something else.

@demeritcowboy demeritcowboy merged commit 5120879 into civicrm:master Sep 21, 2021
@eileenmcnaughton
Copy link
Contributor Author

@demeritcowboy yeah - I did try to do more on 'toContact' last time & hit issues - I think I've figured out the underlying problem now - ie because the static class was having to try to do stuff in preProcessit was insane.... A few more changes like this & it would start to be sane

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants