Skip to content

Commit ee5ccbc

Browse files
authored
Merge branch 'main' into copilot/enable-xdebug-in-behat-tests-again
2 parents 2e0ba0a + 21780c6 commit ee5ccbc

11 files changed

Lines changed: 751 additions & 144 deletions

File tree

‎.github/workflows/issue-triage.yml‎

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,9 +16,14 @@ name: Issue and PR Triage
1616
permissions:
1717
issues: write
1818
pull-requests: write
19-
actions: write
2019
contents: read
2120
models: read
21+
# A caller can only cap a reusable workflow's permissions, never raise them,
22+
# so `actions: write` has to be granted here for the dispatch job downstream
23+
# to work at all. The reusable workflow narrows it to that single job, so the
24+
# `pull_request_target` job does not receive it. Removing it here breaks
25+
# dispatching (see #271/#272); narrow it there instead.
26+
actions: write
2227

2328
jobs:
2429
issue-triage:

‎.readme-partials/USING.md‎

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -119,6 +119,35 @@ Here's how to run your tests against the latest trunk version of WordPress:
119119
WP_VERSION=trunk composer behat
120120
```
121121
122+
#### WordPress Archive
123+
124+
Instead of downloading WordPress from WordPress.org, you can run the tests against an arbitrary
125+
WordPress ZIP archive by setting the `WP_CLI_TEST_CORE_ZIP` environment variable. It accepts either
126+
a path to a local archive or an HTTP(S) URL.
127+
128+
This is useful to test against a WordPress build that has not been released, such as the ZIP file
129+
produced by the WordPress core build process.
130+
131+
```bash
132+
WP_CLI_TEST_CORE_ZIP=~/Downloads/wordpress.zip composer behat
133+
```
134+
135+
The archive may contain WordPress at its root, or wrapped in a single folder — both `wordpress/`
136+
(as used by WordPress.org releases) and `build/` (as used by some WordPress core build artifacts)
137+
work. Archives are extracted once and then cached, keyed by their contents.
138+
139+
`WP_VERSION` still determines which version-specific tags (`@require-wp-6.4`, `@less-than-wp-6.4`)
140+
are filtered out, since the version of a development build cannot be compared meaningfully. It
141+
defaults to `trunk` when an archive is set, which runs every scenario. Set it explicitly when the
142+
archive holds a specific release:
143+
144+
```bash
145+
WP_VERSION=6.4.2 WP_CLI_TEST_CORE_ZIP=~/Downloads/wordpress-6.4.2.zip composer behat
146+
```
147+
148+
Note that steps requesting an explicit version, such as `Given a WP 6.4.2 installation`, keep
149+
downloading that version from WordPress.org and ignore the archive.
150+
122151
#### WP-CLI Binary
123152
124153
You can run the tests against a specific WP-CLI binary, instead of using the one that has been built in your project's `vendor/bin` folder.

‎README.md‎

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -130,6 +130,35 @@ Here's how to run your tests against the latest trunk version of WordPress:
130130
WP_VERSION=trunk composer behat
131131
```
132132
133+
#### WordPress Archive
134+
135+
Instead of downloading WordPress from WordPress.org, you can run the tests against an arbitrary
136+
WordPress ZIP archive by setting the `WP_CLI_TEST_CORE_ZIP` environment variable. It accepts either
137+
a path to a local archive or an HTTP(S) URL.
138+
139+
This is useful to test against a WordPress build that has not been released, such as the ZIP file
140+
produced by the WordPress core build process.
141+
142+
```bash
143+
WP_CLI_TEST_CORE_ZIP=~/Downloads/wordpress.zip composer behat
144+
```
145+
146+
The archive may contain WordPress at its root, or wrapped in a single folder — both `wordpress/`
147+
(as used by WordPress.org releases) and `build/` (as used by some WordPress core build artifacts)
148+
work. Archives are extracted once and then cached, keyed by their contents.
149+
150+
`WP_VERSION` still determines which version-specific tags (`@require-wp-6.4`, `@less-than-wp-6.4`)
151+
are filtered out, since the version of a development build cannot be compared meaningfully. It
152+
defaults to `trunk` when an archive is set, which runs every scenario. Set it explicitly when the
153+
archive holds a specific release:
154+
155+
```bash
156+
WP_VERSION=6.4.2 WP_CLI_TEST_CORE_ZIP=~/Downloads/wordpress-6.4.2.zip composer behat
157+
```
158+
159+
Note that steps requesting an explicit version, such as `Given a WP 6.4.2 installation`, keep
160+
downloading that version from WordPress.org and ignore the archive.
161+
133162
#### WP-CLI Binary
134163
135164
You can run the tests against a specific WP-CLI binary, instead of using the one that has been built in your project's `vendor/bin` folder.

‎bin/run-behat-tests‎

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -89,6 +89,14 @@ else
8989
fi
9090
fi
9191

92+
# When installing from an arbitrary archive, there is no version to resolve against
93+
# WordPress.org. Default to "trunk" so that no @require-wp tags are filtered out, as
94+
# such an archive is usually a development build. Set WP_VERSION explicitly alongside
95+
# WP_CLI_TEST_CORE_ZIP when the archive holds a specific release.
96+
if [ -n "${WP_CLI_TEST_CORE_ZIP-}" ] && [ -z "${WP_VERSION-}" ]; then
97+
export WP_VERSION=trunk
98+
fi
99+
92100
# Turn WP_VERSION into an actual number to make sure our tags work correctly.
93101
if [ "${WP_VERSION-latest}" = "latest" ]; then
94102
export WP_VERSION=$(curl -s https://api.wordpress.org/core/version-check/1.7/ | jq -r ".offers[0].current")

‎features/behat-steps.feature‎

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -389,6 +389,19 @@ Feature: Test that WP-CLI Behat steps work as expected
389389
"""
390390
Then the wp-cli.yml file should exist
391391
And the mock-requests.php file should exist
392+
And the mock-requests-data.php file should exist
393+
394+
When I run `php -l mock-requests.php`
395+
Then STDOUT should contain:
396+
"""
397+
No syntax errors detected
398+
"""
399+
400+
When I run `php -l mock-requests-data.php`
401+
Then STDOUT should contain:
402+
"""
403+
No syntax errors detected
404+
"""
392405

393406
@require-wp
394407
Scenario: Test background process launch

‎phpcs.xml.dist‎

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -98,4 +98,19 @@
9898
<rule ref="WordPress.WP.GlobalVariablesOverride">
9999
<exclude-pattern>*/generate-coverage\.php$</exclude-pattern>
100100
</rule>
101+
102+
<!-- These are stand-alone files that are copied into the test run directory and
103+
executed by the child WP-CLI process, not loaded as part of this package.
104+
They declare a class once per supported Requests major version, and their
105+
method signatures are dictated by the transport interface they implement,
106+
so unused parameters cannot be dropped. -->
107+
<rule ref="Generic.Files.OneObjectStructurePerFile">
108+
<exclude-pattern>*/src/Context/templates/*</exclude-pattern>
109+
</rule>
110+
<rule ref="Generic.Classes.DuplicateClassName">
111+
<exclude-pattern>*/src/Context/templates/*</exclude-pattern>
112+
</rule>
113+
<rule ref="Generic.CodeAnalysis.UnusedFunctionParameter">
114+
<exclude-pattern>*/src/Context/templates/*</exclude-pattern>
115+
</rule>
101116
</ruleset>

‎phpstan.neon.dist‎

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,9 @@ parameters:
77
- tests
88
excludePaths:
99
- tests/data
10+
# Templates are copied into the test run directory and executed by the
11+
# child WP-CLI process, where Requests v1 classes may still exist.
12+
- src/Context/templates
1013
scanDirectories:
1114
- vendor/wp-cli/wp-cli
1215
- vendor/phpunit/php-code-coverage

0 commit comments

Comments
 (0)