afragen / setup-phpunit

Setup PHPUnit for use in Local Lightning
MIT License
20 stars 6 forks source link

Integrate script into Local Add-on #2

Open claygriffiths opened 4 years ago

claygriffiths commented 4 years ago

@afragen reached out saying he'd like to see this ported into an Add-on. I agree! 😃

I'm adding this issue as a way to kick off discussion.

Notes:

At the time of writing, the Add-ons tab in Local is currently hidden. To add and enable Add-ons, Local Beta needs to be used.


Questions:

afragen commented 4 years ago

My thoughts for an add-on would be something along the lines of what is in https://thefragens.com/wp-core-dev-with-local-lightning/

There are a couple of scripts, etc involved, not just this one. 😉

dbeja commented 4 years ago

I think it would be great to be able to run the tests directly from the Add-on UI, and also get the output also on the UI. Some of the options would also be to select the theme or plugin folder where the tests would run.

afragen commented 4 years ago

Also the ability to setup as either core or develop.

dbeja commented 4 years ago

Ok, so I've been playing a bit with developing a Local Add-on and I took the liberty of coming up with this mock (no design).

phpunit-mock

I added 4 buttons:

The output window would show the complete log of phpunit, but on the bottom it would parse the main values of the tests.

Any feedback on this? Am I missing something here? I'm also not sure, if for core/develop we need some extra steps as the setup it's a bit different.

afragen commented 4 years ago

This is wonderful @dbeja!

I had envisioned an Add-on that would also optionally overwrite a WP installation based upon core.git.wordpress.org and develop.git.wordpress.org as in the one-click install from https://thefragens.com/wp-core-dev-with-local-lightning/

I was thinking that testing could actually done in the CLI from Open Site Shell. There are many options to running the setup-phpunit.sh script with differing versions, etc. If those options could be installed and run from the Add-on that would be slick, but I don't think necessary for v1.0

I do like the output display in the Add-on.

Much of the idea for an Add-on is to assist with core development. Running PHPUnit is obviously part of that.

dbeja commented 4 years ago

Thanks, @afragen. Yes, I see, it would be very helpful to be able to have a one-click install of a WP Core environment. Would you say it should be all on the same Add-on? WP Core environment and PHPUnit? Or as two Add-ons?

I'm interested in working on these 2 features, they would be very helpful to WP Development. Would you consider to work with me on this? I could take care of the Add-on structure and UI.

afragen commented 4 years ago

Having as 2 separate add ons would probably be simpler, but there's a lot of overlap. I'm more than happy to help but I'm not at all familiar with the code necessary to create an add on. But most devs wanting to install core will also likely want to have PHPUnit installed too.

Currently the way I use my scripts is to either install the core.git.wordpress.org or develop.git.wordpress.org and then utilize PHPUnit as needed.

You should take a look at the blog post above. There are a couple of other scripts I've written to assist in core development that I also install in the 'one-click' install.

dbeja commented 4 years ago

Yes, I see what you mean. I will follow your entire tutorial and install a core/develop setup to get a feel of what it needs and how it works. I was imagining the core add-on to be just some settings/switches on Utilities tab to run all the needed scripts, and the PHPUnit the above UI and you could use it for core, theme development, plugin development, anything that would use tests, but I see what you mean with having a lot of overlap.

Ok, great, as soon as I'll start working on this I'll create a new repository for this/these add-on(s) and I'll then add you to them and you can help me with the bash scripts.

afragen commented 4 years ago

Hey @brandondove, any thoughts about this?

cliffordp commented 4 years ago

Instead of PHPUnit, I think https://wpbrowser.wptestkit.dev/ is the more appropriate choice, since Local is specific to WP. It has its own functionalities in addition to including Codeception which includes PHPUnit.

Just sharing for your consideration before you get too far into this thing. Not trying to derail any progress, just to help.

@lucatume

brandondove commented 4 years ago

Hey @brandondove, any thoughts about this?

This sounds pretty awesome. I haven't dug into installing or calling external scripts yet in my add-on development. I did see that it's possible though. Cross-platform compatibility will definitely require extra work and consideration though. I wonder if you could (or if it would be useful) to utilize Local's blueprint functionality for building the environments.

afragen commented 4 years ago

This sounds pretty awesome. I haven't dug into installing or calling external scripts yet in my add-on development. I did see that it's possible though. Cross-platform compatibility will definitely require extra work and consideration though. I wonder if you could (or if it would be useful) to utilize Local's blueprint functionality for building the environments.

I think the problem with using a blueprint here is that you want to pull the latest version of trunk and if that means the git.develop.WordPress.org or git.core.WordPress.org those come up very differently. I have most everything working from the scripts but I can't test setup-phpunit.sh on Windows or Linux. I would think that it should work on Linux though.

crstauf commented 7 months ago

It is so frustrating that there still isn't a seemingly easy way to get PHPUnit working within Local. I wish I were more familiar with terminal and VMs and such so I knew exactly what to do. 😞