-
-
Notifications
You must be signed in to change notification settings - Fork 824
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
add contact_id
to email params in emailLetter
function
#22538
Conversation
(Standard links)
|
The problem with putting stuff into core just to support extensions is that it is easy for them to be removed from core later because they are not required by core. Some ways we protect them if we want them not to break later are
Much as I loathe |
@eileenmcnaughton Please help me to use tests because I never used or created them, sorry.
How hard for just one line of code, but I understand, it is important and I have to learn. |
There's a little bit of setup required - see https://docs.civicrm.org/dev/en/latest/testing/#setup (just the first section there - down to where you fill in .cv.json). The main part is setting up an empty test db and TEST_DB_DSN unless you're ok to use the existing database, but it will wipe the data. If you're using a throwaway buildkit site then this should be already done for you. Then, the tests currently use phpunit8, so I'd use that version. And then to run it you need to set Note the test fail here on the PR for CRM_Contribute_Form_Task_PDFLetterCommonTest.testPostProcessGroupByContact is a test you would need to update since it's not expecting contact id. But it means you can probably copy/paste some of that code since it would be a similar test. |
@masetto definitely happy to help you get going on tests - once you have them running it really helps. Do you use buildkit? an IDE? |
@eileenmcnaughton I'm not using buildkit. I have |
Run |
Thanks @demeritcowboy I am so used to phpstorm + buildkit my brain went blank at anything else @braders - you use vscode - do you know if it is possible to run unit tests within vscode? The way I run tests in phpstorm is I right click & select 'debug'.... |
@Eileen I must profess to just letting Jenkins run tests for me - it would be good to figure out how to get them going locally though! In terms of VSCode integration, I think people would generally:
|
I use vscode sometimes - there's a phpunit extension you can install - I don't use it but it might be useful. |
…ty with `contactId` parameter
@eileenmcnaughton Please look at my last commit.
but it never goes inside... |
hi, have you looked at the commits? |
Because the default on that form is to JUST create pdfs, the test would need to pass in email_options to the form in order to get the hook to work for testPostProcess(). If I put in some debugging to output stack traces, the only test that is calling the hook is testPostProcessGroupByContact(). So it's working, but if you wanted it to only run for one test, you would put |
If the |
@masetto I'm sorry I haven't had the bandwidth for this issue over the last week. It looks like @demeritcowboy is 'fairly happy' with this - which I think is a high enough bar if the test will protect this change. Merging |
Overview
I add the
contact_id
to email params inemailLetter()
function.Before
If you use Mail hooks (
alterMailParams
andpostEmailSend
) you do not know which contact you are sending the email to, or at least it is not easy to know.After
Now, if you use
alterMailParams
orpostEmailSend
hooks, you can know contact and get all its details.Technical Details
I use
contact_id
key and notcontactId
because everywhere is called this.Comments
I removed the unnecessary line: