I’m running Local Lightning on a Windows 10 environment and need to setup a test suite so I can run integration test with phpunit. Before the site terminal opened as a docker windows giving me an environment that knew linux commands and could run bash scripts. Now I cannot run “bash setup-phpunit.sh” in it, since it doesn’t know bash, apt-get, or even ls. Afragen’s adaptation of setup-phpunit.sh doesn’t help when there is no environment to run it in.
Been at it for days now, trying other terminals, like git bash and WSL bash (using ubuntu under windows 10), and at some point I got to a point that the script seem to run to it’s closure, only to find that it corrupted my install and I had to reinstall the website. All in all it seems much harder to set this up in Local Lightning than it was in the previous ssh window and I haven’t solved it yet
Anyone know how to do it using the windows install of local Lightning? As of yet it seems that this aspect of local lightning is a large step backwards, and I am frustrated by how difficult this now seems and am in desperate need of some tips from someone that has done it. Please help!
I am testing Local on Windows10 as well. I tried using the new Git Bash with the ‘open site shell’ command.
At first did simply did not do anything (regular CMD box works).
After I started Local as an Administrator, the Git Bash did open a shell prompt and I can use it like normally with git, ls and other unix commands.
GNU bash, version 4.4.23(1)-release (x86_64-pc-msys)
That’s right, but git bash doesn’t have all that is needed to run the phpunit-setup script. For instance it still misses apt-get. I have asked the question to local support by now, but the response was just that my finding was right and since they dropped docket, the new site shell doesn’t offer the same environment as docker did. I was advised to support a feature request to add more support for phpunit to local, but that doesn’t help me now. In the end the conclusion is that local Lightning doesn’t offer support for phpunit integration tests and you need to install some other server environment to perform those tests. So some of the advantage of local is lost during the upgrade to a more fully controlled install. It’s a pitty.
I followed this awesome tut on my Windows 10 laptop recently (mid-Sept 2020), with a few adjustments, and I’m able to run phpunit on Local Lighting.
I created an empty database in my test site using these helpful instructions from Clay:
Adminer may look a little different now. I also added a user with all privileges and used that user’s info in wp_tests_config. You could probably also just use the default root user.
I used cmder for my terminal. That’s what I typically use and like.
Step 8, changing the site URL to have /build at the end, I did manually in the db.
Step 9a: I set up wp_tests_config manually.
Step 9b: I think I had issues with this. But it’s not a deal breaker.
Step 9c: I had already had phpunit installed globally on my machine (following phpunit instructions, linked to from WordPress’s docs, I believe – https://phpunit.readthedocs.io/en/latest/installation.html#windows). I understand it’s a best practice to install it for each project. If the command in 9c doesn’t work for you as is, phpunit’s instructions could be the way to go.
I set a different database prefix for wp_tests_config and wp_config.
I’m sure this can be tweaked and improved. You may want to try a completely different approach. The good news is that it is possible to get phpunit working on Local Lightning on Windows 10.
Note: I’ve had issues when trying to upgrade Local Lightning on Windows, so I’m using an earlier version.