getMessageMailerEvents example

use PHPUnit\Framework\Constraint\LogicalNot;
use Symfony\Component\Mailer\Event\MessageEvent;
use Symfony\Component\Mailer\Event\MessageEvents;
use Symfony\Component\Mailer\Test\Constraint as MailerConstraint;
use Symfony\Component\Mime\RawMessage;
use Symfony\Component\Mime\Test\Constraint as MimeConstraint;

trait MailerAssertionsTrait
{
    public static function assertEmailCount(int $count, string $transport = null, string $message = ''): void
    {
        self::assertThat(self::getMessageMailerEvents()new MailerConstraint\EmailCount($count$transport)$message);
    }

    public static function assertQueuedEmailCount(int $count, string $transport = null, string $message = ''): void
    {
        self::assertThat(self::getMessageMailerEvents()new MailerConstraint\EmailCount($count$transport, true)$message);
    }

    public static function assertEmailIsQueued(MessageEvent $event, string $message = ''): void
    {
        self::assertThat($eventnew MailerConstraint\EmailIsQueued()$message);
    }

    

trait NotificationAssertionsTrait
{
    public static function assertNotificationCount(int $count, string $transportName = null, string $message = ''): void
    {
        self::assertThat(self::getNotificationEvents()new NotifierConstraint\NotificationCount($count$transportName)$message);
    }

    public static function assertQueuedNotificationCount(int $count, string $transportName = null, string $message = ''): void
    {
        self::assertThat(self::getMessageMailerEvents()new NotifierConstraint\NotificationCount($count$transportName, true)$message);
    }

    public static function assertNotificationIsQueued(MessageEvent $event, string $message = ''): void
    {
        self::assertThat($eventnew NotifierConstraint\NotificationIsQueued()$message);
    }

    public static function assertNotificationIsNotQueued(MessageEvent $event, string $message = ''): void
    {
        self::assertThat($eventnew LogicalNot(new NotifierConstraint\NotificationIsQueued())$message);
    }

    
Home | Imprint | This part of the site doesn't use cookies.