Detecting a mail was sent using swift mailer in current scope

211 views Asked by At

I'm building functional tests for a Symfony2 app and need to know when an email was sent but not from an api request. (This link is not what i'm looking for: http://symfony.com/doc/current/cookbook/email/testing.html)

The flow of the application is the following:

  • User create a personalized video
  • A flattening request (to create the final video) is sent to a GNASH server via a queue
  • Once GNASH is done it posts a message to another queue
  • We process the queue using a daemon
  • While processing the responses which can arrive anytime, the system dispatches a VideoFlatteningCompleteEvent
  • This even is caught and sends an email to the owner to tell him the video is ready.

My goal:

  • Dispatch the VideoFlatteningCompleteEvent by myself since it takes too many steps to reproduce the workflow event with well forged tests (easy)
  • Collect the mails sent or find a way to intercept the mail to validate it was sent once the event is dispatched.

Anyone has a clue?

1

There are 1 answers

3
Mathieu Dumoulin On BEST ANSWER

Found a solution after some digging. Using a plugin for swiftmailer, i'm able to collect the emails sent using the Send event. This way, i can, on the fly, see what emails were sent and not. Probably something similar is used for the DataCollector in Symfony2's profiler.