diff --git a/features/scaffold-plugin-tests.feature b/features/scaffold-plugin-tests.feature index b224dbd3..4376b8da 100644 --- a/features/scaffold-plugin-tests.feature +++ b/features/scaffold-plugin-tests.feature @@ -143,6 +143,31 @@ Feature: Scaffold plugin unit tests SKIP_DB_CREATE=true """ + Scenario: Scaffold plugin tests ignore invalid version in readme.txt + Given a WP install + And I run `wp scaffold plugin hello-world --skip-tests` + + When I run `wp plugin path hello-world --dir` + Then save STDOUT as {PLUGIN_DIR} + + Given a {PLUGIN_DIR}/readme.txt file: + """ + === Hello World === + Requires at least: 6.4; echo exploit # + Tested up to: 6.4 + """ + + When I run `wp scaffold plugin-tests hello-world --ci=circle` + Then STDOUT should not be empty + And the {PLUGIN_DIR}/.circleci/config.yml file should not contain: + """ + 6.4; echo exploit # + """ + And the {PLUGIN_DIR}/.circleci/config.yml file should contain: + """ + bash bin/install-wp-tests.sh wordpress_test root '' 127.0.0.1 latest $SKIP_DB_CREATE + """ + Scenario: Scaffold plugin tests with Gitlab as the provider Given a WP install And I run `wp scaffold plugin hello-world --skip-tests` diff --git a/src/Scaffold_Command.php b/src/Scaffold_Command.php index f1a3e6be..dc3441b1 100644 --- a/src/Scaffold_Command.php +++ b/src/Scaffold_Command.php @@ -893,9 +893,11 @@ private function scaffold_plugin_theme_tests( $args, $assoc_args, $type ) { if ( file_exists( "{$target_dir}/readme.txt" ) ) { $readme_content = (string) file_get_contents( "{$target_dir}/readme.txt" ); - preg_match( '/Requires at least\:(.*)\n/m', $readme_content, $matches ); - if ( isset( $matches[1] ) && $matches[1] ) { - $wp_versions_to_test[] = trim( $matches[1] ); + if ( preg_match( '/Requires at least\:(.*)(?:\r?\n|$)/i', $readme_content, $matches ) ) { + $version = trim( $matches[1] ); + if ( preg_match( '/^[0-9]+(?:\.[0-9]+)*(?:-[a-zA-Z0-9.]+)?$/', $version ) ) { + $wp_versions_to_test[] = $version; + } } } $wp_versions_to_test[] = 'latest';