From e5fa09075ada7f53a16988c2d754ba3c8096a5b1 Mon Sep 17 00:00:00 2001 From: Michael Withagen Date: Tue, 7 Jan 2025 08:16:55 +0100 Subject: [PATCH 1/5] #96 Make it possible to filter on multiple values --- src/Core_Language_Command.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/Core_Language_Command.php b/src/Core_Language_Command.php index 81ac2a98..4b6fb77a 100644 --- a/src/Core_Language_Command.php +++ b/src/Core_Language_Command.php @@ -126,7 +126,7 @@ function ( $translation ) use ( $available, $current_locale, $updates ) { foreach ( $translations as $key => $translation ) { foreach ( array_keys( $translation ) as $field ) { - if ( isset( $assoc_args[ $field ] ) && $assoc_args[ $field ] !== $translation[ $field ] ) { + if ( isset( $assoc_args[ $field ] ) && ! in_array( $translation[ $field ], array_map( 'trim', explode( ',', $assoc_args[ $field ] ) ), true ) ) { unset( $translations[ $key ] ); } } From cd74883ce4caba77310f12c3ef3c88cdaca29bd5 Mon Sep 17 00:00:00 2001 From: Michael Withagen Date: Tue, 7 Jan 2025 09:03:16 +0100 Subject: [PATCH 2/5] Write test listing languages by multiple statusses --- features/language-core.feature | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/features/language-core.feature b/features/language-core.feature index e861a237..d8aad7c2 100644 --- a/features/language-core.feature +++ b/features/language-core.feature @@ -535,3 +535,15 @@ Feature: Manage translation files for a WordPress install """ en_US """ + + @require-wp-4.0 + Scenario: List languages by multiple statuses + Given a WP install + And an empty cache + + When I run `wp language core install nl_NL` + When I run `wp language core list --fields=language,status --status=active,installed` + Then STDOUT should be a table containing rows: + | language | status | + | en_US | active | + | nl_NL | installed | From b15b0bc97031b56c188fc70c41d231ff901ad021 Mon Sep 17 00:00:00 2001 From: Michael Withagen Date: Tue, 7 Jan 2025 15:44:37 +0100 Subject: [PATCH 3/5] Add support for multiple statuses to other commands + write tests --- features/language-core.feature | 1 + features/language-plugin.feature | 13 +++++++++++++ features/language-theme.feature | 14 ++++++++++++++ src/Plugin_Language_Command.php | 2 +- src/Theme_Language_Command.php | 2 +- 5 files changed, 30 insertions(+), 2 deletions(-) diff --git a/features/language-core.feature b/features/language-core.feature index d8aad7c2..2a99810f 100644 --- a/features/language-core.feature +++ b/features/language-core.feature @@ -547,3 +547,4 @@ Feature: Manage translation files for a WordPress install | language | status | | en_US | active | | nl_NL | installed | + And STDERR should be empty diff --git a/features/language-plugin.feature b/features/language-plugin.feature index c55a6647..b48a510f 100644 --- a/features/language-plugin.feature +++ b/features/language-plugin.feature @@ -439,3 +439,16 @@ Feature: Manage translation files for a WordPress install jetpack,invalid_lang,"not available" """ And STDERR should be empty + + @require-wp-4.0 + Scenario: List languages by multiple statuses + Given a WP install + And an empty cache + And I run `wp language plugin install akismet nl_NL` + + When I run `wp language plugin list --all --fields=plugin,language,status --status=active,installed` + Then STDOUT should be a table containing rows: + | plugin | language | status | + | akismet | en_US | active | + | akismet | nl_NL | installed | + And STDERR should be empty diff --git a/features/language-theme.feature b/features/language-theme.feature index b210ae8e..10112b62 100644 --- a/features/language-theme.feature +++ b/features/language-theme.feature @@ -314,3 +314,17 @@ Feature: Manage translation files for a WordPress install twentysixteen,de_DE,"not installed" """ And STDERR should be empty + + @require-wp-4.0 + Scenario: List languages by multiple statuses + Given a WP install + And an empty cache + And I run `wp theme install twentyten` + And I run `wp language theme install twentyten nl_NL` + + When I run `wp language theme list twentyten --fields=language,status --status=active,installed` + Then STDOUT should be a table containing rows: + | language | status | + | en_US | active | + | nl_NL | installed | + And STDERR should be empty diff --git a/src/Plugin_Language_Command.php b/src/Plugin_Language_Command.php index 96364061..24f2c644 100644 --- a/src/Plugin_Language_Command.php +++ b/src/Plugin_Language_Command.php @@ -154,7 +154,7 @@ public function list_( $args, $assoc_args ) { // Support features like --status=active. foreach ( array_keys( $translation ) as $field ) { - if ( isset( $assoc_args[ $field ] ) && $assoc_args[ $field ] !== $translation[ $field ] ) { + if ( isset( $assoc_args[ $field ] ) && ! in_array( $translation[ $field ], array_map( 'trim', explode( ',', $assoc_args[ $field ] ) ), true ) ) { continue 2; } } diff --git a/src/Theme_Language_Command.php b/src/Theme_Language_Command.php index aaf173e0..f3e67b33 100644 --- a/src/Theme_Language_Command.php +++ b/src/Theme_Language_Command.php @@ -160,7 +160,7 @@ function ( $file ) { // Support features like --status=active. foreach ( array_keys( $translation ) as $field ) { - if ( isset( $assoc_args[ $field ] ) && $assoc_args[ $field ] !== $translation[ $field ] ) { + if ( isset( $assoc_args[ $field ] ) && ! in_array( $translation[ $field ], array_map( 'trim', explode( ',', $assoc_args[ $field ] ) ), true ) ) { continue 2; } } From dd7e4819ba3fdb5fe3cbc332784a9adc1cf77c90 Mon Sep 17 00:00:00 2001 From: Michael Withagen Date: Tue, 7 Jan 2025 15:52:31 +0100 Subject: [PATCH 4/5] Add force to theme install to make sure it exists in all php versions --- features/language-theme.feature | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/features/language-theme.feature b/features/language-theme.feature index 10112b62..8b7935e8 100644 --- a/features/language-theme.feature +++ b/features/language-theme.feature @@ -319,7 +319,7 @@ Feature: Manage translation files for a WordPress install Scenario: List languages by multiple statuses Given a WP install And an empty cache - And I run `wp theme install twentyten` + And I run `wp theme install twentyten --force` And I run `wp language theme install twentyten nl_NL` When I run `wp language theme list twentyten --fields=language,status --status=active,installed` From 007f77da39994eb46714c4210117d7ee2e3c763c Mon Sep 17 00:00:00 2001 From: Michael Withagen Date: Tue, 7 Jan 2025 16:12:46 +0100 Subject: [PATCH 5/5] Update test, move when into prep of the scenario using and --- features/language-core.feature | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/features/language-core.feature b/features/language-core.feature index 2a99810f..ad13b2c2 100644 --- a/features/language-core.feature +++ b/features/language-core.feature @@ -540,8 +540,8 @@ Feature: Manage translation files for a WordPress install Scenario: List languages by multiple statuses Given a WP install And an empty cache + And I run `wp language core install nl_NL` - When I run `wp language core install nl_NL` When I run `wp language core list --fields=language,status --status=active,installed` Then STDOUT should be a table containing rows: | language | status |