2017 © Pedro Peláez
 

symfony-bundle mailer-test-bundle

Allows for easy testing of the mailer/emails when using the SwiftMailerBundle.

image

xm/mailer-test-bundle

Allows for easy testing of the mailer/emails when using the SwiftMailerBundle.

  • Monday, February 26, 2018
  • by darrylhein
  • Repository
  • 2 Watchers
  • 0 Stars
  • 50 Installations
  • PHP
  • 0 Dependents
  • 0 Suggesters
  • 0 Forks
  • 0 Open issues
  • 3 Versions
  • 14 % Grown

The README.md

XMMailerTestBundle

Allows for easy testing of the mailer/emails when using the SwiftMailerBundle., (*1)

Installation

Step 1: Download the Bundle

This package is not on Packagist, so the repository will need to be added manually in composer.json, (*2)

Open a command console, enter your project directory and execute the following command to download the latest stable version of this bundle:, (*3)

$ php composer.phar require --dev xm/mailer-test-bundle

This command requires Composer., (*4)

Step 2: Enable the Bundle

Then, enable the bundle by adding it to the list of registered bundles in the app/AppKernel.php file of your project:, (*5)

<?php
// app/AppKernel.php

// ...
class AppKernel extends Kernel
{
    public function registerBundles()
    {
        // ...
        if (in_array($this->getEnvironment(), array('dev', 'test'))) {
            // ...
            $bundles[] = new XM\MailerTestBundle\XMMailerTestBundle();
        }
    }
}

Usage

Below is how this bundle would be typically used., (*6)

<?php

namespace Tests\AppBundle\EventSubscriber;

use Symfony\Component\EventDispatcher\GenericEvent;
use XM\MailerTestBundle\Test\MailerTestCase;

class EventSubscriberTest extends MailerTestCase
{
    public function testEvent()
    {
        $mailerPlugin = $this->getMailerPlugin();

        $event = new GenericEvent();

        $this->container->get('app.listener')
            ->onEvent($event);

        // make sure email was sent
        $this->assertNotNull($mailerPlugin->beforeSendEvent);
        $this->assertNotNull($mailerPlugin->sendEvent);

        // grab message and make sure it matches what we wanted
        $msg = $mailerPlugin->sendEvent->getMessage();

        $expected = 'Expected Subject';
        $this->assertEquals($expected, $msg->getSubject());

        $this->assertContains('Expected part of email body', $msg->getBody());
    }
}

The Versions

26/02 2018

dev-master

9999999-dev https://github.com/xmmedia/XMMailerTestBundle

Allows for easy testing of the mailer/emails when using the SwiftMailerBundle.

  Sources   Download

MIT

The Requires

 

by Darryl Hein

26/02 2018

0.1.1

0.1.1.0 https://github.com/xmmedia/XMMailerTestBundle

Allows for easy testing of the mailer/emails when using the SwiftMailerBundle.

  Sources   Download

MIT

The Requires

 

by Darryl Hein

19/07 2017

0.1

0.1.0.0 https://github.com/xmmedia/XMMailerTestBundle

Allows for easy testing of the mailer/emails when using the SwiftMailerBundle.

  Sources   Download

MIT

The Requires

 

by Darryl Hein