Problem/Motivation
Sending a test email to an email of the user should be sent in the context of that user, same as normal emails.
Proposed resolution
Remaining tasks
User interface changes
API changes
| Comment | File | Size | Author |
|---|---|---|---|
| #8 | test-send-user-2421477-8.patch | 4.89 KB | arla |
| #8 | test-send-user-2421477-8.interdiff.txt | 1.02 KB | arla |
| #3 | test-send-user-2421477-3.patch | 4.81 KB | arla |
Comments
Comment #1
miro_dietikerPushing to major as this leads to wrong test results.
Comment #2
arla commentedThe current user is set to the test address user, but only if that user is also a subscriber.
Simplified snippet from the current Drupal\simplenews\Mail\Mailer class:
You can work around this by just subscribing the user of the test address to a newsletter and then unsubscribing again. That will create a Subscriber entity so simplenews_subscriber_load_by_mail() will return it.
Not sure which sort of fix is adequate:
Comment #3
arla commentedUsing user_load_by_mail() and a new convenience method Subscriber::fillFromUser().
Comment #5
miro_dietikerDirection makes sense... but there are test fails introduced. :-)
Comment #6
arla commentedDidn't get the fail locally. Retested and now it seems fine?
Comment #7
berdiri'm not sure the fallback here is correct.
If you select some arbitrary email, I'm not sure if the desired behavior is that it really uses your account if none is available that uses that mail?
I think the fallback should be the current code, basically.
Comment #8
arla commentedIt wouldn't use "your account" because a few lines earlier it switches to anonymous. But on the other hand, it then sets the mail to empty, which is not very good for sending ;)
Fixed and tested manually.
Comment #9
berdirThat makes more sense. Committed.