Local Lightning + PHPUnit + PhpStorm

Hi, there is a detailed post about using PHPUnit and PHPStorm with Local but, yet again, this is something that doesn’t work with Local Lightning. How can I use PHPStore to run PHPUnit tests with Local Lightning? There’s no “ports” plugin in Lightning, so how can I use apt-get on my site through Lightning? Also, why can’t we use ports with Lightning? Here’s the conversation I’m referencing which details how to use PHPUnit with PHPStorm:

This is a significant problem for me, too. I am currently sitting on Local Classic because there I couldn’t figure out a way to-do this (after HOURS of trying).

Hello! I’m sorry it’s taken so long for me to get a reply here, but I’d love to help get things working!

The reason this was more direct under Local Classic was that the site was within a Virtual Machine and so there was less of a chance of the user’s tools bleeding into the site.

A few questions about the Local Lightning configuration and how the host machine is set up:

  • Do you have Composer installed already within your regular, non-Local terminal?

  • Is PHPUnit included as a dev dependency for the project you are working on, or are you wanting to manually run PHPUnit from the global installation?

Can you see if something in this post helps?

https://thefragens.com/wp-core-dev-with-local-lightning/

I’ve specifically written a script to install PHPUnit in the site shell for Local Lighting. Specifically https://github.com/afragen/setup-phpunit/blob/master/setup-phpunit.sh

I don’t use PHPStorm. I run PHPUnit inside the site shell.

1 Like

I suppose that’s a really good distinction that @afragen brings up:

@Blylier and @alexstandiford – are you trying to run the WordPress core unit tests, or just run PHPUnit in general?

In either case, Andy’s post outlines some great info, but if you are just trying to run PHPunit (and not the whole Core test suite) then the setup should be much simpler.

I tried this, however it looks like it uses apt-get to install the needed packages but that isn’t available in the Local shell, so it errors out with “ERROR Missing packages. Make sure you’re connected to the internet.”
I should specify I’m using Local on a mac

@paul2 actually it uses Homebrew on a Mac. Check the readme. :wink:

the issue was that for mac os, it installs homebrew and wget but not the other packages, so I installed those manually, then reran the script and it worked.

Still, the files generated by wp scaffold plugin-tests weren’t working with this config so some changes to the paths were necessary.

@paul2 Specifically which packages did you manually install? I’ve got wget, brew, composer, and xcode-select; not sure what’s missing.