ton/email-bundle

Email bundle for test environment of Symfony2

Installs: 339

Dependents: 0

Suggesters: 0

Security: 0

Stars: 0

Watchers: 3

Forks: 5

Open Issues: 0

Type:symfony-bundle

v1.0.0 2014-09-13 01:43 UTC

This package is auto-updated.

Last update: 2024-12-13 21:22:24 UTC


README

Email bundle for test environment of Symfony2. It allows to store emails as *.eml files and read them after that.

Setup

config_test.yml

swiftmailer:
    transport: file

and 'swiftmailer.transport.file' instead of 'file' for SwiftmailerBundle V2.2.?

Memory transport

PhpUnitTest.php

use Ton\EmailBundle\EventListener\EmailListener;

    /**
     * @todo check multiple initialization
     */
    protected function registerEmailListener()
    {
        $container = $this->getContainer();
        $mailer = $container->get('mailer');
        $plugin = new EmailListener();
        $mailer->registerPlugin($plugin);
        return $plugin;
    }

    /**
     * @test
     */
    public function sendEmail()
    {
        $email = $this->registerEmailListener();
        $email->clean();

        // Send Email

        $this->assertCount(1, $email->getPreSendMessages());
        $email->getPreSendMessage(0);
    }