Skip to content
Merged
Show file tree
Hide file tree
Changes from 4 commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 7 additions & 1 deletion composer.json
Comment thread
swissspidy marked this conversation as resolved.
Original file line number Diff line number Diff line change
Expand Up @@ -16,9 +16,15 @@
"homepage": "https://www.alainschlesser.com"
}
],
"repositories": [
{
"type": "vcs",
"url": "https://github.com/wp-cli/wp-config-transformer"
}
],
"require": {
"wp-cli/wp-cli": "^2.13",
"wp-cli/wp-config-transformer": "^1.4.0"
"wp-cli/wp-config-transformer": "dev-main"
Comment thread
swissspidy marked this conversation as resolved.
Outdated
},
"require-dev": {
"wp-cli/db-command": "^1.3 || ^2",
Expand Down
39 changes: 39 additions & 0 deletions features/config-has.feature
Original file line number Diff line number Diff line change
Expand Up @@ -170,3 +170,42 @@ Feature: Check whether the wp-config.php file or the wp-custom-config.php file h
"""
Error: Found both a constant and a variable 'SOME_NAME' in the 'wp-custom-config.php' file. Use --type=<type> to disambiguate.
"""

Scenario Outline: Find constants and variables in a config with complex expressions
Given an empty directory
And a wp-includes/version.php file:
"""
<?php $wp_version = '6.3';
"""
And a wp-config.php file:
"""
<?php
$do_redirect = 'https://example.com' . $_SERVER['REQUEST_URI'];
$table_prefix = 'wp_';
define( 'DB_NAME', 'wp' );
define( 'CUSTOM_CSS', 'body {
color: red;
}' );
$after_multiline = 'found';
$long_url = 'https://example.com'
. '/path';
define( 'ALLOWED_HOSTS', array(
'example.com',
) );
$after_array_define = 'found';
"""
Comment thread
pwtyler marked this conversation as resolved.

When I run `wp config has <name> --type=<type>`
Then STDOUT should be empty
And the return code should be 0

Examples:
| name | type | description |
| do_redirect | variable | concatenation expression itself |
| table_prefix | variable | variable after concatenation |
| DB_NAME | constant | constant after concatenation variable |
| CUSTOM_CSS | constant | constant with multiline string value |
| after_multiline | variable | variable after multiline string value |
| long_url | variable | multiline concatenation variable |
| ALLOWED_HOSTS | constant | constant with multiline raw value |
| after_array_define | variable | variable after multiline raw define |