ton/email-bundle

This package is not installable via Composer 1.x, please make sure you upgrade to Composer 2+. Read more about our Composer 1.x deprecation policy.

Email bundle for test environment of Symfony2

Installs: 336

Dependents: 0

Suggesters: 0

Security: 0

Stars: 0

Watchers: 2

Forks: 7

Open Issues: 0

Type:symfony-bundle

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

This package is auto-updated.

Last update: 2021-11-13 14:26:55 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);
    }