Closed modelm closed 4 years ago
@boonebgorges What do you think? I have no objections against it. Do you see any drawback?
Yup, would be great!
@modelm Go ahead and send us a PR. I'll help as much as I can. :)
I implemented a first pass at this a while back: https://github.com/buddypress/wp-cli-buddypress/compare/master...modelm:feature-test-scaffold
Unfortunately I discovered the functions used by WP_CLI\Scaffold_Command
to create, write, and validate files are all static private methods, so I could not call them directly to edit the files & add BP-specific code.
Instead, I create two new files, install-bp-tests.sh
& bootstrap-buddypress.php
and expect the user to call the install script after already having scaffolded the WP core tests via wp scaffold plugin-tests
. The install script injects a require
line to include the BP bootstrap code in the core test bootstrap file.
So, this does make scaffolding BP tests with a single command possible, but it's not the approach I had in mind initially and I'm unsure whether it's worth including in the current state. Ideally, the private methods in Scaffold_Command could be made protected to facilitate this kind of thing, but I haven't pursued that yet. I'm open to suggestion about what direction to take at this point.
@modelm
I went to the CLI guys for feedback on your first strategy. My goal was to find out possible drawbacks in changing the methods to protected
to accomodate our use case: https://wordpress.slack.com/archives/C02RP4T41/p1542408188299200
Alain hit me back with a good use case of not doing that. Here is his feedback: https://wordpress.slack.com/archives/C02RP4T41/p1542451701305700
For now, I'd recommend leaving as is. It's not perfect, but it gets the job done.
Another option would be to copy the create, write and validate methods to use inside BuddyPress. In this way, it'd not be dependent on the WP_CLI\Scaffold_Command
.
As Alain mentioned in his feedback, the Scaffold_Command
file could use some refactor, but until we have a "good" basis, we can do with what you created here.
@boonebgorges What do you think?
FYI, I have an almost done PoC based on @modelm 's version. Sending a PR soon.
As a plugin developer I rely on
wp scaffold plugin-tests
a lot. I often end up customizing the scaffolded code to load BP along with WP for BP_UnitTestCase extensions. It would be great if I could scaffold a BP-specific test framework with a single command.If you're willing to include this feature I'd like to help build it, but I wanted to ask in case it already exists or isn't something you think should be included for some reason.