Add functional tests for CLI commands #3076
Labels
Infrastructure
Changes impacting testing infrastructure or build tooling
P2
Low priority
Testing
Issues related with Unit, E2E, Smoke, and other testing requirements/needs
WP-CLI
WS:Perf
Work stream for Metrics, Performance and Optimizer
Milestone
The obvious choice would be reusing
wp-cli/wp-cli-tests
to write Behat tests, but there seems to be a blocking technical issue so far that doesn't allow this without resorting to a hack.The main issue is that you need to install the plugin within the WordPress installation that Behat will set up. To do so, you use a built plugin version and send it over for installation as a ZIP archive.
However, this built version will contain the same Composer autoloader (with the same hash included in the class name) than the Composer autoloader that Behat was actually run from. This causes a redeclaration error from PHP when the WordPress installation tries to load the plugin.
I can think of two possible solutions right now to solve this:
1.) Rebuild a fresh ZIP archive with a regenerated autoloader that will have a different hash than the one Behat was loaded from.
2.) Avoid using Behat directly as a Composer dependency and use a binary/Phar instead, that comes with its own autoloader.
Before trying to tackle this, I'd like to investigate this from the WP-CLI side, to see whether this can be streamlined through the official package first.
Related #1815
The text was updated successfully, but these errors were encountered: