Replies: 21 comments 15 replies
-
Do you already have the phpunit tests in there? Have you composer-installed phpunit? |
Beta Was this translation helpful? Give feedback.
-
Hi @rfay , Yes, I have installed phpunit on my machine with homebrew. And I also installed it, locally in the plugin. |
Beta Was this translation helpful? Give feedback.
-
You need phpunit in your code's vendor directory. Install it with composer. Having it on your computer is not relevant. The code in the container cannot access anything on your computer. Please use |
Beta Was this translation helpful? Give feedback.
-
phpunit when installed is usually in vendor/bin/phpunit, for example. see https://github.com/weitzman/ddev-selenium-standalone-chrome and its readme. |
Beta Was this translation helpful? Give feedback.
-
@mandrasch can you offer any help here? (@mandrasch is an expert with WP and DDEV) |
Beta Was this translation helpful? Give feedback.
-
@rfay I forgot to mentionned it, I also did try it in ssh in the container. Here is the error when I then start my unit tests. mac-dw-eti@rabaischocs-web:/var/www/html/wp-content/plugins/rc-reports$ ./vendor/bin/phpunit I did follow the setup instruction : https://pippinsplugins.com/unit-tests-wordpress-plugins-setting-up-testing-suite/. you set up wordpress with phpunit, with the wp cli it uses a bash script. After the script has been run. And then try to do any unit test I get the error mentionned. From our understanding the error would be in the bash script. The script seems to not know it's in a container. |
Beta Was this translation helpful? Give feedback.
-
@rfay By the way, I really like working with ddev. |
Beta Was this translation helpful? Give feedback.
-
Have you run bin/install-wp-tests.sh? It seems to install something in /tmp/wordpress-tests-lib, and /tmp is a volatile directory in ddev (it gets recreated on every start) |
Beta Was this translation helpful? Give feedback.
-
Yes I did run bin/install-wp-tests.sh command. |
Beta Was this translation helpful? Give feedback.
-
You'll need to run it each time you restart, since /tmp/ goes away on restart. You need to look in /tmp/wordpress-tests-lib and see what's there or not there. Make sure everything you're doing right now is inside the container ( Lots of other people have had this problem before you, https://www.google.com/search?q=Could+not+find+%2Ftmp%2Fwordpress-tests-lib%2Fincludes%2Ffunctions.php%2C+have+you+run+bin%2Finstall-wp-tests.sh&oq=Could+not+find+%2Ftmp%2Fwordpress-tests-lib%2Fincludes%2Ffunctions.php%2C+have+you+run+bin%2Finstall-wp-tests.sh&aqs=chrome..69i57j0i512.239j0j9&sourceid=chrome&ie=UTF-8 |
Beta Was this translation helpful? Give feedback.
-
No response after quite some time, I'll convert this to a discussion. |
Beta Was this translation helpful? Give feedback.
-
@rfay I was able to run the ddev ssh, and run the WordPress scaffold command with wp-cli. But I still have issues. I wish there were a guide on how to setup PhpUnit with WordPress on DDEV. Unfortunatly, so far all my tests have gone cold. @mandrasch Have you ever setup a PhpUnit in a WordPress plugin ? |
Beta Was this translation helpful? Give feedback.
-
I will look into using wp-browser to run all my tests. I'll let you know if I was able to connect this. |
Beta Was this translation helpful? Give feedback.
-
@rfay I was able to install wp-browser. I'm following the VVV setup, because VVV works with Containers, from my understanding. I'm trying to create database in mysql. With those 2 commands : And it's asking me my password. Which password should it be ? I tried, my computer one, the db password and no password. Any idea for the password ? |
Beta Was this translation helpful? Give feedback.
-
Hi Randy, Here is my summary on the steps to setup DDEV with WP-Browser. I did follow this guide https://wpbrowser.wptestkit.dev/tutorials/vvv-setup. I just made a few changes to be able to to build on DDEV.
/** MySQL database password */ for thoses lines
You can use any of the vendor/bin/codecept run ... commands with --debug to have more details if you have a problem. // .env.testing example |
Beta Was this translation helpful? Give feedback.
-
All tests works. So I'm ready to write my first test. |
Beta Was this translation helpful? Give feedback.
-
Need help on writing your first Acceptance test : https://wp-punk.com/simple-start-with-acceptance-testing-for-wordpress/ |
Beta Was this translation helpful? Give feedback.
-
@rfay How can we do that in a container based system like DDEV ? |
Beta Was this translation helpful? Give feedback.
-
ddev-selenium-standalone-chrome can be used for running Chrome with PHPUnit test inside DDEV on Drupal. It might give you hints. There are also a couple of other addons you can find by running: Or try DDEV-contrib |
Beta Was this translation helpful? Give feedback.
-
Is there an existing issue for this?
Run a Diagnostic and Paste Link Here
I wanted to know if there is a way to setup or guide on how to setup a WordPress plugin to use the phpunit with DDEV ?
So far my reasearch and tests have not been successfull.
Thank you for your help,
Expected Behavior
I want to use the wp cli scaffold command with the use of their script to install and use phpunit.
But it does not work.
Actual Behavior
I want to setup a WordPress plugin to include phpunit tests.
Steps To Reproduce
No response
Anything else?
I wanted to know if there is a way to setup or guide on how to setup a WordPress plugin to use the phpunit with DDEV ?
So far my reasearch and tests have not been successfull.
Thank you for your help,
Beta Was this translation helpful? Give feedback.
All reactions