Skip to content

Add behat test for config has after concatenation assignment#220

Open
pwtyler wants to merge 4 commits intowp-cli:mainfrom
pwtyler:test/config-has-concat-variable
Open

Add behat test for config has after concatenation assignment#220
pwtyler wants to merge 4 commits intowp-cli:mainfrom
pwtyler:test/config-has-concat-variable

Conversation

@pwtyler
Copy link
Copy Markdown
Contributor

@pwtyler pwtyler commented Apr 2, 2026

Summary

  • Adds a behat scenario to config-has.feature that verifies wp config has finds variables and constants when the wp-config.php contains a variable assignment with string concatenation (e.g. $x = 'foo' . $bar;)

Depends on wp-cli/wp-config-transformer#64

Dependency note

wp-cli/wp-config-transformer#64 is now merged. composer.json temporarily points at dev-main via a VCS repository entry so CI runs against the fixed code. Once a release of wp-config-transformer is cut, this PR will be updated to pin to that version and the repositories override removed.

@github-actions
Copy link
Copy Markdown
Contributor

github-actions bot commented Apr 2, 2026

Hello! 👋

Thanks for opening this pull request! Please check out our contributing guidelines. We appreciate you taking the initiative to contribute to this project.

Contributing isn't limited to just code. We encourage you to contribute in the way that best fits your abilities, by writing tutorials, giving a demo at your local meetup, helping other users with their support questions, or revising our documentation.

Here are some useful Composer commands to get you started:

  • composer install: Install dependencies.
  • composer test: Run the full test suite.
  • composer phpcs: Check for code style violations.
  • composer phpcbf: Automatically fix code style violations.
  • composer phpunit: Run unit tests.
  • composer behat: Run behavior-driven tests.

To run a single Behat test, you can use the following command:

# Run all tests in a single file
composer behat features/some-feature.feature

# Run only a specific scenario (where 123 is the line number of the "Scenario:" title)
composer behat features/some-feature.feature:123

You can find a list of all available Behat steps in our handbook.

@github-actions github-actions bot added command:config-has Related to 'config has' command scope:testing Related to testing labels Apr 2, 2026
Copy link
Copy Markdown

@gemini-code-assist gemini-code-assist bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Code Review

This pull request introduces a new test scenario to verify that the wp config has command correctly identifies variables and constants when they follow a concatenation assignment. A review comment points out that the wp-config.php content in the test is missing the required <?php opening tag, which is necessary for the PHP parser to correctly process the file and for the test to function as intended.

wp-cli/wp-config-transformer#64 is merged but not yet released.
Using the VCS source + dev-main so CI can run against the fixed
code. Will revert to a version constraint once a release is cut.
@codecov
Copy link
Copy Markdown

codecov bot commented Apr 10, 2026

Codecov Report

✅ All modified and coverable lines are covered by tests.

📢 Thoughts on this report? Let us know!

pwtyler added 2 commits April 10, 2026 15:16
Expands test coverage to mirror the edge cases in the transformer's
own ConcatenationTest: concatenation expressions, variables after
concatenation, multiline string values, and multiline raw expressions
(array defines, multi-line concatenation).
@swissspidy swissspidy marked this pull request as ready for review April 11, 2026 15:59
@swissspidy swissspidy requested a review from a team as a code owner April 11, 2026 15:59
Copilot AI review requested due to automatic review settings April 11, 2026 15:59
@swissspidy swissspidy added this to the 2.5.1 milestone Apr 11, 2026
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Adds coverage to ensure wp config has can detect constants/variables in wp-config.php even when assignments include concatenation and other multi-line/complex expressions, and temporarily updates dependency resolution to include the upstream fix.

Changes:

  • Added a new Behat Scenario Outline in config-has.feature to cover concatenation, multiline strings, and multiline define() values.
  • Updated composer.json to pull wp-cli/wp-config-transformer from dev-main via a VCS repository override (pending a tagged release).

Reviewed changes

Copilot reviewed 2 out of 2 changed files in this pull request and generated 1 comment.

File Description
features/config-has.feature Adds a scenario outline to validate wp config has detection across complex wp-config expressions.
composer.json Temporarily points wp-cli/wp-config-transformer to dev-main using a VCS repository for CI coverage of the upstream fix.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

"require": {
"wp-cli/wp-cli": "^2.13",
"wp-cli/wp-config-transformer": "^1.4.0"
"wp-cli/wp-config-transformer": "dev-main"
Copy link

Copilot AI Apr 11, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Requiring wp-cli/wp-config-transformer as dev-main (combined with the VCS repository override above) makes installs non-deterministic and can break CI unexpectedly as main moves. Consider pinning to a specific commit hash or a tagged pre-release version for reproducibility, and then switching back to a stable semver constraint once a release is cut.

Suggested change
"wp-cli/wp-config-transformer": "dev-main"
"wp-cli/wp-config-transformer": "dev-main#<full-commit-hash>"

Copilot uses AI. Check for mistakes.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

command:config-has Related to 'config has' command scope:testing Related to testing

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants