Skip to content
Merged
Show file tree
Hide file tree
Changes from all 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
25 changes: 25 additions & 0 deletions features/scaffold-plugin-tests.feature
Original file line number Diff line number Diff line change
Expand Up @@ -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 #
"""
Comment on lines +162 to +165
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`
Expand Down
8 changes: 5 additions & 3 deletions src/Scaffold_Command.php
Original file line number Diff line number Diff line change
Expand Up @@ -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';
Expand Down
Loading