Skip to content

trevorbicewebdesign/codeception-mailpit

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

28 Commits
 
 
 
 
 
 

Repository files navigation

Codeception Mailpit Module

Provides test helpers for Codeception to facilitate email testing with Mailpit. This module allows you to search for and retrieve email content from Mailpit during your tests, making it easy to verify email functionality, extract activation keys, and more.

Overview

The Mailpit module integrates with Codeception using Guzzle to interact with Mailpit’s API. It provides methods to:

  • Search Emails: Retrieve the most recent email(s) based on search criteria.
  • Fetch Full Email Content: After searching, fetch the complete content of an email by its ID.
  • Extract Information: Easily extract details such as activation keys for further assertions in your tests.
  • Email Assertions for Codeception:

Installation

Install the module via Composer:

composer require dev trevorbicewebdesign/codeception-mailpit

Configuration

Add the module to your Codeception suite configuration (for example, in your acceptance.suite.yml):

modules:
  enabled:
    - Mailpit
  config:
    Mailpit:
      base_uri: 'http://localhost:10006'
  • base_uri: The base URL for your Mailpit installation.

Usage

Once installed and configured, you can use the module in your tests. For example:

Mailpit Module API Methods

  • getLastEmailId() - Get the mailpit message id of the most recent email.
  • getEmailById($id) - Retrieves an email by its ID.
  • getEmailBySubject($subject) - Retrieves the ID of the most recent email that matches the given subject.

Assertions

  • assertEmailTextContains($messageId, $expectedText)
  • assertEmailTextEquals($messageId, $extectedText)
  • assertEmailSubjectEquals($messageId, $expectedSubject)
  • assertEmailSubjectContains($messageId, $expectedSubject)
  • assertEmailHasHeaders($messageId,$expectedHeaders)

About

Provides test helpers for Codeception when testing email functionality with Mailpit

Topics

Resources

Stars

Watchers

Forks

Packages

No packages published

Languages