From 1bd600b183cf7b0f66a5eed1d56530eeeec92928 Mon Sep 17 00:00:00 2001 From: Pascal Birchler Date: Tue, 1 Sep 2026 12:34:31 +0200 Subject: [PATCH 1/2] Fix PHPCS errors in Behat test files --- features/config-add.feature | 2 +- features/config-create.feature | 22 +++++++++++----------- features/config-get-field.feature | 8 ++++---- features/config-has.feature | 16 +++++++++++----- features/config-list.feature | 28 ++++++++++++++-------------- features/config-set.feature | 4 ++-- features/config-update.feature | 2 +- 7 files changed, 44 insertions(+), 38 deletions(-) diff --git a/features/config-add.feature b/features/config-add.feature index 90acbddf..6e7b7551 100644 --- a/features/config-add.feature +++ b/features/config-add.feature @@ -105,7 +105,7 @@ Feature: Add a constant or variable to wp-config.php file define( 'CONST_A', 'val-a' ); /** ANCHOR */ define( 'CONST_B', 'val-b' ); - require_once( ABSPATH . 'wp-settings.php' ); + require_once ABSPATH . 'wp-settings.php'; """ When I run `wp config add SOME_NAME some_value --anchor="/** ANCHOR */" --placement=before --separator="\n"` diff --git a/features/config-create.feature b/features/config-create.feature index 8a6a669f..0dffcb36 100644 --- a/features/config-create.feature +++ b/features/config-create.feature @@ -248,24 +248,24 @@ Feature: Create a wp-config file // The WP_CLI_TEST_DBSOCKET variable can be set in the environment to // override the default locations and will take precedence. if ( ! empty( getenv( 'WP_CLI_TEST_DBSOCKET' ) ) ) { - echo getenv( 'WP_CLI_TEST_DBSOCKET' ); - exit(0); + echo getenv( 'WP_CLI_TEST_DBSOCKET' ); + exit( 0 ); } // From within Behat, the WP_CLI_TEST_DBSOCKET will be mapped to the internal // DB_SOCKET variable, as Behat pushes a new environment context. $locations = [ - '{DB_SOCKET}', - '/var/run/mysqld/mysqld.sock', - '/tmp/mysql.sock', + '{DB_SOCKET}', + '/var/run/mysqld/mysqld.sock', + '/tmp/mysql.sock', ]; foreach ( $locations as $location ) { - if ( ! empty( $location ) && file_exists( $location ) ) { - echo $location; - exit(0); - } + if ( ! empty( $location ) && file_exists( $location ) ) { + echo $location; + exit( 0 ); + } } echo 'No socket found'; - exit(1); + exit( 1 ); """ When I run `php find-socket.php` @@ -371,7 +371,7 @@ Feature: Create a wp-config file And a wp-config.php file: """ + + J=FA3Si$i8uco>+6vB0&aej6X4r@2dc]V}|iFE!{CjOA*u#g4@Y.2j'); - define('NONCE_KEY', 'O..4n~e~(~:7NGyA!q.(`:X,(RcR(n_o|&(*hKrX2+9D=,&1k2k-;>Y_@X+,!6g!'); - define('SECURE_AUTH_SALT', 'VNH|C>w-z?*dtP4ofy!v%RumM.}ug]mx7$QZW|C-R4T`d-~x|xvL{Xc_5C89K(,^'); - define('LOGGED_IN_SALT', 'Iwtez|Q`M l7lup; x&ml8^C|Lk&X[3/-l!$`P3GM$7:WI&X$Hn)unjZ9u~g4m[c'); - define('NONCE_SALT', 'QxcY|80 $f_dRkn*Liu|Ak*aas41g(q5X_h+m8Z$)tf6#TZ+Q,D#%n]g -{=mj1)'); + define( 'AUTH_KEY', '7mj0&+HVh{90t.S]m{u)$\'tCCB$:.[7}jAf`)~hS{ZL#v+&F#kA^p|*RJ=FA3Si$i8uco>+6vB0&aej6X4r@2dc]V}|iFE!{CjOA*u#g4@Y.2j' ); + define( 'NONCE_KEY', 'O..4n~e~(~:7NGyA!q.(`:X,(RcR(n_o|&(*hKrX2+9D=,&1k2k-;>Y_@X+,!6g!' ); + define( 'SECURE_AUTH_SALT', 'VNH|C>w-z?*dtP4ofy!v%RumM.}ug]mx7$QZW|C-R4T`d-~x|xvL{Xc_5C89K(,^' ); + define( 'LOGGED_IN_SALT', 'Iwtez|Q`M l7lup; x&ml8^C|Lk&X[3/-l!$`P3GM$7:WI&X$Hn)unjZ9u~g4m[c' ); + define( 'NONCE_SALT', 'QxcY|80 $f_dRkn*Liu|Ak*aas41g(q5X_h+m8Z$)tf6#TZ+Q,D#%n]g -{=mj1)' ); $table_prefix = 'wp_'; @@ -362,7 +362,7 @@ Feature: List the values of a wp-config.php file /* That's all, stop editing! Happy publishing. */ if ( ! defined( 'ABSPATH' ) ) { - define( 'ABSPATH', dirname( __FILE__ ) . '/' ); + define( 'ABSPATH', __DIR__ . '/' ); } require_once ABSPATH . 'wp-settings.php'; @@ -428,7 +428,7 @@ Feature: List the values of a wp-config.php file define( 'WP_DEBUG', true ); define( 'WP_DEBUG_LOG', true ); define( 'WP_DEBUG_DISPLAY', false ); - require_once( ABSPATH . 'wp-settings.php' ); + require_once ABSPATH . 'wp-settings.php'; """ When I run `wp config list --fields=name,value,type --format=table` @@ -444,7 +444,7 @@ Feature: List the values of a wp-config.php file """ define( 'WP_DEBUG', true ); define( 'WP_DEBUG_DISPLAY', false ); - require_once( ABSPATH . 'wp-settings.php' ); + require_once ABSPATH . 'wp-settings.php'; """ When I run `wp config list WP_DEBUG --strict --format=json` @@ -465,7 +465,7 @@ Feature: List the values of a wp-config.php file """ define( 'WP_DEBUG', true ); define( 'WP_DEBUG_DISPLAY', false ); - require_once( ABSPATH . 'wp-settings.php' ); + require_once ABSPATH . 'wp-settings.php'; """ When I run `wp config list WP_DEBUG --strict --format=dotenv` diff --git a/features/config-set.feature b/features/config-set.feature index 7afcc562..130eddf7 100644 --- a/features/config-set.feature +++ b/features/config-set.feature @@ -351,7 +351,7 @@ Feature: Set the value of a constant or variable defined in wp-config.php file a define( 'CONST_A', 'val-a' ); /** ANCHOR */ define( 'CONST_B', 'val-b' ); - require_once( ABSPATH . 'wp-settings.php' ); + require_once ABSPATH . 'wp-settings.php'; """ When I run `wp config set SOME_NAME some_value --type=constant --anchor="/** ANCHOR */" --placement=before --separator="\n"` @@ -390,7 +390,7 @@ Feature: Set the value of a constant or variable defined in wp-config.php file a define( 'CONST_A', 'val-a' ); /** ANCHOR */ define( 'CONST_B', 'val-b' ); - require_once( ABSPATH . 'wp-settings.php' ); + require_once ABSPATH . 'wp-settings.php'; """ When I run `wp config set SOME_NAME some_value --type=constant --anchor="/** ANCHOR */" --placement=before --separator="\n" --config-file="wp-custom-config.php"` diff --git a/features/config-update.feature b/features/config-update.feature index f666f40e..0ce08439 100644 --- a/features/config-update.feature +++ b/features/config-update.feature @@ -156,7 +156,7 @@ Feature: Update or add a constant or variable in wp-config.php file define( 'CONST_A', 'val-a' ); /** ANCHOR */ define( 'CONST_B', 'val-b' ); - require_once( ABSPATH . 'wp-settings.php' ); + require_once ABSPATH . 'wp-settings.php'; """ When I run `wp config update SOME_NAME some_value --anchor="/** ANCHOR */" --placement=before --separator="\n"` From f127270e6ef62db59fd7b46fabbd69b5845bd2c8 Mon Sep 17 00:00:00 2001 From: Pascal Birchler Date: Tue, 1 Sep 2026 11:07:20 +0000 Subject: [PATCH 2/2] Match the expected wp-config.php files to the fixtures they come from Each of these scenarios writes a wp-config.php, runs `wp config add`, `set` or `update` over it, and then states what the file should look like afterwards. The fixture is created by a step that makes a `.php` file, so the fixer reached it and dropped the parentheses from its `require_once`; the expectation quotes the same file back but is not a `.php` file step, so it was left as it was. The two stopped agreeing and four scenarios failed on the first expectation, taking the second one of each with them. The expectations now say what the commands actually produce. Only the `require_once` line differs, and none of these scenarios is about the form it takes: they are about where a constant is placed relative to the anchor. Co-Authored-By: Claude Opus 5 Claude-Session: https://claude.ai/code/session_01SeC6Day9YHEaDh4NZZtDSS --- features/config-add.feature | 4 ++-- features/config-set.feature | 8 ++++---- features/config-update.feature | 4 ++-- 3 files changed, 8 insertions(+), 8 deletions(-) diff --git a/features/config-add.feature b/features/config-add.feature index 6e7b7551..2ea71399 100644 --- a/features/config-add.feature +++ b/features/config-add.feature @@ -119,7 +119,7 @@ Feature: Add a constant or variable to wp-config.php file define( 'SOME_NAME', 'some_value' ); /** ANCHOR */ define( 'CONST_B', 'val-b' ); - require_once( ABSPATH . 'wp-settings.php' ); + require_once ABSPATH . 'wp-settings.php'; """ When I run `wp config add ANOTHER_NAME another_value --anchor="/** ANCHOR */" --placement=after --separator="\n"` @@ -134,5 +134,5 @@ Feature: Add a constant or variable to wp-config.php file /** ANCHOR */ define( 'ANOTHER_NAME', 'another_value' ); define( 'CONST_B', 'val-b' ); - require_once( ABSPATH . 'wp-settings.php' ); + require_once ABSPATH . 'wp-settings.php'; """ diff --git a/features/config-set.feature b/features/config-set.feature index 130eddf7..1ee8cdb5 100644 --- a/features/config-set.feature +++ b/features/config-set.feature @@ -365,7 +365,7 @@ Feature: Set the value of a constant or variable defined in wp-config.php file a define( 'SOME_NAME', 'some_value' ); /** ANCHOR */ define( 'CONST_B', 'val-b' ); - require_once( ABSPATH . 'wp-settings.php' ); + require_once ABSPATH . 'wp-settings.php'; """ When I run `wp config set ANOTHER_NAME another_value --type=constant --anchor="/** ANCHOR */" --placement=after --separator="\n"` @@ -380,7 +380,7 @@ Feature: Set the value of a constant or variable defined in wp-config.php file a /** ANCHOR */ define( 'ANOTHER_NAME', 'another_value' ); define( 'CONST_B', 'val-b' ); - require_once( ABSPATH . 'wp-settings.php' ); + require_once ABSPATH . 'wp-settings.php'; """ Scenario: Additions can be properly placed in wp-custom-config.php @@ -404,7 +404,7 @@ Feature: Set the value of a constant or variable defined in wp-config.php file a define( 'SOME_NAME', 'some_value' ); /** ANCHOR */ define( 'CONST_B', 'val-b' ); - require_once( ABSPATH . 'wp-settings.php' ); + require_once ABSPATH . 'wp-settings.php'; """ When I run `wp config set ANOTHER_NAME another_value --type=constant --anchor="/** ANCHOR */" --placement=after --separator="\n" --config-file="wp-custom-config.php"` @@ -419,5 +419,5 @@ Feature: Set the value of a constant or variable defined in wp-config.php file a /** ANCHOR */ define( 'ANOTHER_NAME', 'another_value' ); define( 'CONST_B', 'val-b' ); - require_once( ABSPATH . 'wp-settings.php' ); + require_once ABSPATH . 'wp-settings.php'; """ diff --git a/features/config-update.feature b/features/config-update.feature index 0ce08439..3f15cc23 100644 --- a/features/config-update.feature +++ b/features/config-update.feature @@ -170,7 +170,7 @@ Feature: Update or add a constant or variable in wp-config.php file define( 'SOME_NAME', 'some_value' ); /** ANCHOR */ define( 'CONST_B', 'val-b' ); - require_once( ABSPATH . 'wp-settings.php' ); + require_once ABSPATH . 'wp-settings.php'; """ When I run `wp config update SOME_NAME updated_value --anchor="/** ANCHOR */" --placement=before --separator="\n"` @@ -184,5 +184,5 @@ Feature: Update or add a constant or variable in wp-config.php file define( 'SOME_NAME', 'updated_value' ); /** ANCHOR */ define( 'CONST_B', 'val-b' ); - require_once( ABSPATH . 'wp-settings.php' ); + require_once ABSPATH . 'wp-settings.php'; """