Explicit theme support in wp-browser 1.18

Support for WordPress themes built into wp-browser.

The problem

I’ve mulled over the possibility to add explicit theme support to wp-browser for quite some time but have always snoozed the thought knowing theme testing has been possible for a long time.
I’ve recently been asked 3 times in a week how to do it and that’s probably a signal that’s not as intuitive as I thought.

Local config solution

Where theme testing might get hairy is in the configuration of the WPLoader module; its inner mechanics, those of the WordPress core automated testing suite, are often lost to many expecting “magic” to happen.
It’s been some time that the WPLoader module has been accepting a configFile parameter: that should be the path, or paths, to a list of files that should be loaded before the module runs; it’s essentially the place where custom constants or bootstrap files specific to alternative WordPress installation structures should live.
If the only need is to have a specific theme activated before the tests then that’s as easy as creating a test specific config file:

<?php
global $wp_tests_options;

$wp_tests_options['stylesheet'] = 'child'; // my theme slug
$wp_tests_options['template']   = 'twentysixteen'; // my parent theme slug

and requiring it in the WPLoader module configuration:

 class_name: WploaderTester
modules:
    enabled:
        - \Helper\Wploadersuite
        - WPLoader
    config:
        WPLoader:
            wpRootFolder: "/tmp/wordpress"
            dbName: "wploader"
            dbHost: "localhost"
            dbUser: root
            dbPassword: ''
            wpDebug: true
            dbCharset: "utf8"
            dbCollate: ""
            tablePrefix: "wp_"
            domain: "wordpress.dev"
            adminEmail: "[email protected]"
            title: "Test"
            phpBinary: "php"
            language: ""
            configFile: "tests/tests-config.php"
            plugins: []
            activatePlugins: []
            booststrapActions: []

see this example for a pods based theme.

Built-in solution

The latest version of wp-browser allows skipping that step completely and adding a parameter in the module configuration directly:

class_name: WploaderTester
modules:
    enabled:
        - \Helper\Wploadersuite
        - WPLoader
    config:
        WPLoader:
            wpRootFolder: "/tmp/wordpress"
            dbName: "wploader"
            dbHost: "localhost"
            dbUser: root
            dbPassword: ''
            wpDebug: true
            dbCharset: "utf8"
            dbCollate: ""
            tablePrefix: "wp_"
            domain: "wordpress.dev"
            adminEmail: "[email protected]"
            title: "Test"
            phpBinary: "php"
            language: ""
            theme: ['parent', 'child']
            plugins: []
            activatePlugins: []
            booststrapActions: []

The theme parameter can be a string to activate an independent theme or an array, like [ 'parent', 'child' ] to activate a child theme.

On GitHub

Version 1.18 or wp-browser is already published on GitHub, run composer update to fetch it.

Probably related

I appreciate your input