ton/email-bundle

Symfony2测试环境的邮件包

安装: 338

依赖者: 0

建议者: 0

安全性: 0

星星: 0

关注者: 3

分支: 5

开放问题: 0

类型:symfony-bundle

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

This package is auto-updated.

Last update: 2024-09-13 20:38:58 UTC


README

Symfony2测试环境的邮件包。允许将邮件存储为*.eml文件并在之后读取它们。

配置

config_test.yml

swiftmailer:
    transport: file

并且对于SwiftmailerBundle V2.2.?使用'swiftmailer.transport.file'而不是'file'。

内存传输

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);
    }