WordPress Db Codeception module

In an effort to streamline WordPress acceptance and functional testing even more I’ve begun today the development of the WPDb module as an extension of Codeception own Db Module.
I’ve packed the module together with the WPBrowser module for a contextual reason and to allow more decoupled acceptance and functional testing.

The configuration

After adding the module to the development requirements using Composer a functional or acceptance test configuration will require the exact same configuration parameters as those passed to the default Db module like

# Codeception Test Suite Configuration

# suite for acceptance tests.
# perform tests in browser using the WebDriver or PhpBrowser.
# If you need both WebDriver and PHPBrowser tests - create a separate suite.

class_name: AcceptanceTester
        - AcceptanceHelper
        - WPBrowser
        - WPDb
            url: 'http://example.local'
            adminUsername: 'admin'
            adminPassword: 'admin'
            adminUrl: '/wp-core/wp-admin'
            dsn: 'mysql:host=;dbname=test'
            user: 'root'
            password: 'root'
            dump: 'tests/_data/dump.sql'
            populate: true
            cleanup: false
            tablePrefix: 'xvi'

with an optional tablePrefix parameter allowing for table prefix specification, it will default to wp.

A small core

The module packs little punch right not addressing my actual testing needs (mainly options) but I plan to keep developing it and add more methods to allow future method calling like


and so on. What’s important to my growing Codeception module creation skills is that the module will work as a drop-in replacement of the Db module thanks to class inheritance and nails the basic of a Codeception module leaving the extension of its features to an exercise in imagination.

On GitHub

Being on Packagist the module is on GitHub as well.