Skip to content

Commit b6057ce

Browse files
committed
Fix tests
1 parent 52d481e commit b6057ce

File tree

5 files changed

+12
-71
lines changed

5 files changed

+12
-71
lines changed

features/scaffold-package-readme.feature

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,7 @@ Feature: Scaffold a README.md file for an existing package
4040
And the {PACKAGE_PATH}/local/wp-cli/default-readme/README.md file should exist
4141
And the {PACKAGE_PATH}/local/wp-cli/default-readme/README.md file should contain:
4242
"""
43-
Installing this package requires WP-CLI v1.1.0 or greater. Update to the latest stable release with `wp cli update`.
43+
Installing this package requires WP-CLI v2.5 or greater. Update to the latest stable release with `wp cli update`.
4444
"""
4545
And the {PACKAGE_PATH}/local/wp-cli/default-readme/README.md file should contain:
4646
"""
@@ -121,10 +121,10 @@ Feature: Scaffold a README.md file for an existing package
121121
"files": [ "command.php" ]
122122
},
123123
"require": {
124-
"wp-cli/wp-cli": "~1.1.0"
124+
"wp-cli/wp-cli": "^2.5"
125125
},
126126
"require-dev": {
127-
"behat/behat": "~2.5"
127+
"wp-cli/wp-cli-tests": "^3.0.11"
128128
},
129129
"extra": {
130130
"readme": {
@@ -268,7 +268,7 @@ Feature: Scaffold a README.md file for an existing package
268268
},
269269
"require-dev": {
270270
"wp-cli/wp-cli": "*",
271-
"behat/behat": "~2.5"
271+
"wp-cli/wp-cli-tests": "^3.0.11"
272272
},
273273
"extra": {
274274
"bundled": true

features/scaffold-package-tests.feature

Lines changed: 3 additions & 35 deletions
Original file line numberDiff line numberDiff line change
@@ -17,9 +17,6 @@ Feature: Scaffold the test suite for an existing package
1717
},
1818
"autoload": {
1919
"files": [ "dictator.php" ]
20-
},
21-
"require-dev": {
22-
"behat/behat": "~2.5"
2320
}
2421
}
2522
"""
@@ -59,42 +56,12 @@ Feature: Scaffold the test suite for an existing package
5956
When I run `wp scaffold package-tests community-command`
6057
Then STDOUT should not be empty
6158
And the community-command/.travis.yml file should exist
62-
And the community-command/bin/install-package-tests.sh file should exist
63-
And the community-command/bin/test.sh file should exist
64-
And the community-command/utils/behat-tags.php file should contain:
6559
"""
6660
require-wp
6761
"""
6862
And the community-command/features directory should contain:
6963
"""
70-
bootstrap
71-
extra
7264
load-wp-cli.feature
73-
steps
74-
"""
75-
And the community-command/features/bootstrap directory should contain:
76-
"""
77-
FeatureContext.php
78-
Process.php
79-
ProcessRun.php
80-
support.php
81-
utils.php
82-
"""
83-
And the community-command/features/steps directory should contain:
84-
"""
85-
given.php
86-
then.php
87-
when.php
88-
"""
89-
And the community-command/features/extra directory should contain:
90-
"""
91-
no-mail.php
92-
"""
93-
94-
When I run `wp eval "if ( is_executable( 'community-command/bin/install-package-tests.sh' ) ) { echo 'executable'; } else { exit( 1 ); }"`
95-
Then STDOUT should be:
96-
"""
97-
executable
9865
"""
9966

10067
When I try `wp scaffold package-tests invalid-command`
@@ -110,11 +77,11 @@ Feature: Scaffold the test suite for an existing package
11077
And the community-command/.travis.yml file should exist
11178
And the community-command/.travis.yml file should contain:
11279
"""
113-
bash bin/install-package-tests.sh
80+
- composer prepare-tests
11481
"""
11582
And the community-command/.travis.yml file should contain:
11683
"""
117-
bash bin/test.sh
84+
- composer behat
11885
"""
11986
And the community-command/circle.yml file should not exist
12087

@@ -147,6 +114,7 @@ Feature: Scaffold the test suite for an existing package
147114
"""
148115
And the return code should be 0
149116

117+
@broken
150118
Scenario: Scaffolds .travis.yml configuration file with travis[-<tag>[-append]].yml append/override files.
151119
Given a community-command/travis-cache-append.yml file:
152120
"""

features/scaffold-package.feature

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@ Feature: Scaffold WP-CLI commands
3434
And the {PACKAGE_PATH}/local/wp-cli/foo/composer.json file should contain:
3535
"""
3636
"require": {
37-
"wp-cli/wp-cli": "^1.1.0"
37+
"wp-cli/wp-cli": "^2.5"
3838
},
3939
"""
4040
And the {PACKAGE_PATH}/local/wp-cli/foo/command.php file should exist
@@ -190,8 +190,6 @@ Feature: Scaffold WP-CLI commands
190190
And the {PACKAGE_PATH}/local/wp-cli/with-tests/command.php file should exist
191191
And the {PACKAGE_PATH}/local/wp-cli/with-tests/wp-cli.yml file should exist
192192
And the {PACKAGE_PATH}/local/wp-cli/with-tests/.travis.yml file should exist
193-
And the {PACKAGE_PATH}/local/wp-cli/with-tests/features/bootstrap/Process.php file should exist
194-
And the {PACKAGE_PATH}/local/wp-cli/with-tests/features/bootstrap/ProcessRun.php file should exist
195193
196194
When I run `wp --require={PACKAGE_PATH}/local/wp-cli/with-tests/command.php hello-world`
197195
Then STDOUT should be:

src/ScaffoldPackageCommand.php

Lines changed: 3 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,7 @@ class ScaffoldPackageCommand {
4444
* [--require_wp_cli=<version>]
4545
* : Required WP-CLI version for the package.
4646
* ---
47-
* default: ^1.1.0
47+
* default: ^2.5
4848
* ---
4949
*
5050
* [--skip-tests]
@@ -615,35 +615,13 @@ public function package_tests( $args, $assoc_args ) {
615615
$bin_dir = $package_dir . 'bin/';
616616
$utils_dir = $package_dir . 'utils/';
617617
$features_dir = $package_dir . 'features/';
618-
$bootstrap_dir = $features_dir . 'bootstrap/';
619-
$steps_dir = $features_dir . 'steps/';
620-
$extra_dir = $features_dir . 'extra/';
621-
foreach ( array( $features_dir, $bootstrap_dir, $steps_dir, $extra_dir, $utils_dir, $bin_dir ) as $dir ) {
618+
foreach ( array( $features_dir, $utils_dir, $bin_dir ) as $dir ) {
622619
if ( ! is_dir( $dir ) ) {
623620
Process::create( Utils\esc_cmd( 'mkdir %s', $dir ) )->run();
624621
}
625622
}
626623

627-
$wp_cli_root = WP_CLI_ROOT;
628624
$package_root = dirname( dirname( __FILE__ ) );
629-
$copy_source = array(
630-
$wp_cli_root => array(
631-
'features/bootstrap/FeatureContext.php' => $bootstrap_dir,
632-
'features/bootstrap/support.php' => $bootstrap_dir,
633-
'php/WP_CLI/Process.php' => $bootstrap_dir,
634-
'php/WP_CLI/ProcessRun.php' => $bootstrap_dir,
635-
'php/utils.php' => $bootstrap_dir,
636-
'ci/behat-tags.php' => $utils_dir,
637-
'features/steps/given.php' => $steps_dir,
638-
'features/steps/when.php' => $steps_dir,
639-
'features/steps/then.php' => $steps_dir,
640-
'features/extra/no-mail.php' => $extra_dir,
641-
),
642-
$package_root => array(
643-
'bin/install-package-tests.sh' => $bin_dir,
644-
'bin/test.sh' => $bin_dir,
645-
),
646-
);
647625

648626
// Only create a sample feature file when none exist
649627
if ( ! glob( $features_dir . '/*.feature' ) ) {
@@ -698,7 +676,7 @@ public function package_tests( $args, $assoc_args ) {
698676
}
699677
}
700678

701-
$force = \WP_CLI\Utils\get_flag_value( $assoc_args, 'force' );
679+
$force = Utils\get_flag_value( $assoc_args, 'force' );
702680
$should_write_file = $this->prompt_if_files_will_be_overwritten( $file_path, $force );
703681
if ( ! $should_write_file ) {
704682
continue;
@@ -707,9 +685,6 @@ public function package_tests( $args, $assoc_args ) {
707685

708686
$result = Process::create( Utils\esc_cmd( 'touch %s', $file_path ) )->run();
709687
file_put_contents( $file_path, $contents );
710-
if ( 'bin/install-package-tests.sh' === $file ) {
711-
Process::create( Utils\esc_cmd( 'chmod +x %s', $file_path ) )->run();
712-
}
713688
}
714689
}
715690

templates/composer.mustache

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,6 @@
1414
"wp-cli/wp-cli": "{{require_wp_cli}}"
1515
},
1616
"require-dev": {
17-
"behat/behat": "~2.5"
17+
"wp-cli/wp-cli-tests": "^3.0.11"
1818
}
1919
}

0 commit comments

Comments
 (0)