Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add wp-env and utilize for running PHPUnit locally #778

Merged
merged 4 commits into from
May 3, 2022
Merged

Conversation

westonruter
Copy link
Collaborator

@westonruter westonruter commented Apr 30, 2022

This incorporates work from @delawski in ampproject/amp-wp#6802, as well as prior work from @pierlon in ampproject/amp-wp#5201.

In order to run tests with Xdebug in IntelliJ/PhpStorm in the included wp-env environment:

  1. Open Preferences and go to Languages & Frameworks > PHP.

  2. Open Frameworks and under WordPress, toggle on to Enable WordPress integration.

For the WordPress installation path, obtain the root via npm run wp-env install-path and then append /wordpress-develop/src. For example:

/Users/westonruter/.wp-env/e6c93f608f26ae7e0e7a5f1fa29a6a3e/wordpress-develop/src

(The hash will be different on your system.)

Then add this path without /src to the PHP Include Path:

/Users/westonruter/.wp-env/e6c93f608f26ae7e0e7a5f1fa29a6a3e/wordpress-develop
  1. Then open the Servers section and add a pwa server with the host set to host.docker.internal and port to 8888, with the project root mapping to /var/www/html/wp-content/plugins/pwa:

image

Also under Include path add the path mappings from /src and /tests from the previous step to map to /var/www/html/ and /var/www/wordpress-develop/tests respectively:

image

  1. Open the Debug section, and configure the External connections and Xdebug as following (which it may be by default):

image

@westonruter westonruter added this to the 0.7 milestone Apr 30, 2022
@codecov-commenter
Copy link

codecov-commenter commented Apr 30, 2022

Codecov Report

Merging #778 (5cebfbd) into develop (7ade9ff) will not change coverage.
The diff coverage is n/a.

@@            Coverage Diff             @@
##             develop     #778   +/-   ##
==========================================
  Coverage      19.01%   19.01%           
  Complexity       346      346           
==========================================
  Files             57       57           
  Lines           2324     2324           
==========================================
  Hits             442      442           
  Misses          1882     1882           
Flag Coverage Δ
php 19.01% <ø> (ø)
unit 19.01% <ø> (ø)

Flags with carried forward coverage won't be shown. Click here to find out more.


Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update 7ade9ff...5cebfbd. Read the comment docs.

@westonruter
Copy link
Collaborator Author

I always get tripped up on configuring Xdebug with PhpStorm/IntelliJ, so if anyone has improvements to what I've outlined above I'd appreciate it. I want to make sure the best most-streamlined practice is followed. The notes are based on configuring a plugin-specific project, where the project root is the PWA repo root.

@westonruter westonruter merged commit 03819fe into develop May 3, 2022
@westonruter westonruter deleted the add/wp-env branch May 3, 2022 17:58
westonruter added a commit that referenced this pull request May 3, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants