Added support for one of WordPress most useful features in WPBrowser.
It’s been quite some time WordPress introduced support for symbolically linked plugins and themes and I’ve used the features extensively in my local setup.
In an effort to make that possibility easy to use in the tests too I’ve pushed version 1.10.10 of WPBrowser to GitHub.
Copying the readme text below.
tad\WPBrowser\Extension\Symlinker extension provides an automation to have the Codeception root directory symbolically linked in a WordPress local installation.
3.9 WordPress supports this feature (with some precautions) and the extension takes charge of:
- symbolically linking a plugin or theme folder in the specified destination before any suite boots up
- unlinking that symbolic link after all of the suites did run
It’s the equivalent of doing something like this from the command line (on a Mac):
ln -s /my/central/plugin/folder/my-plugin /my/local/wordpress/installation/wp-content/plugins/my-plugin /my/central/plugin/folder/my-plugin/vendor/bin/codecept run rm -rf /my/local/wordpress/installation/wp-content/plugins/my-plugin
The extension needs small configuration in the
extensions: enabled: - tad\WPBrowser\Extension\Symlinker config: tad\WPBrowser\Extension\Symlinker: mode: plugin destination: /my/local/wordpress/installation/wp-content/plugins
The arguments are:
mode– can be
themeand indicates whether the current Codeception root folder being symlinked is a plugin or a theme one
destination– the absolute path to the WordPress local installation plugins or themes folder; to take the never-ending variety of possible setups into account the extension will make no checks on the nature of the destination: could be any folder.
As of Codeception version
2.1.8 enabling and disabling extensions on an environment base is not possible; this means the code below will not work (but sure it would be nice):
# Codeception Test Suite Configuration # suite for WordPress acceptance tests. # perform tests in browser using WPBrowser or WPWebDriver modules. class_name: AcceptanceTester modules: enabled: - WPBrowser - WPDb - \Helper\Acceptance env: single: modules: config: WPBrowser: url: 'http://wp.dev' extensions: config: tad\WPBrowser\Extension\Symlinker: mode: plugin destination: /Users/Luca/Sites/wp/wp-content/plugins multisite: modules: config: WPBrowser: url: 'http://mu.dev' extensions: config: tad\WPBrowser\Extension\Symlinker: mode: plugin destination: /Users/Luca/Sites/mu/wp-content/plugins
I will work on some alternate syntax waiting for environment nested extension configuration to happen.