Skip to content

Commit aef5217

Browse files
Remove wp scaffold package-tests
It's been broken in a while, and is now included in https://github.com/wp-cli/scaffold-package-command
1 parent 649ee18 commit aef5217

6 files changed

Lines changed: 0 additions & 268 deletions

File tree

features/scaffold.feature

Lines changed: 0 additions & 74 deletions
Original file line numberDiff line numberDiff line change
@@ -219,80 +219,6 @@ Feature: WordPress code scaffolding
219219
executable
220220
"""
221221
222-
Scenario: Scaffold package tests
223-
Given a WP install
224-
Given a community-command/command.php file:
225-
"""
226-
<?php
227-
"""
228-
And a community-command/composer.json file:
229-
"""
230-
{
231-
"name": "wp-cli/community-command",
232-
"description": "A demo community command.",
233-
"license": "MIT",
234-
"minimum-stability": "dev",
235-
"require": {
236-
},
237-
"autoload": {
238-
"files": [ "dictator.php" ]
239-
},
240-
"require-dev": {
241-
"behat/behat": "~2.5"
242-
}
243-
}
244-
"""
245-
And a invalid-command/command.php file:
246-
"""
247-
<?php
248-
"""
249-
250-
When I run `wp scaffold package-tests community-command`
251-
Then STDOUT should not be empty
252-
And the community-command/.travis.yml file should exist
253-
And the community-command/bin/install-package-tests.sh file should exist
254-
And the community-command/utils/behat-tags.php file should contain:
255-
"""
256-
require-wp
257-
"""
258-
And the community-command/utils/get-package-require-from-composer.php file should exist
259-
And the community-command/features directory should contain:
260-
"""
261-
bootstrap
262-
extra
263-
load-wp-cli.feature
264-
steps
265-
"""
266-
And the community-command/features/bootstrap directory should contain:
267-
"""
268-
FeatureContext.php
269-
Process.php
270-
support.php
271-
utils.php
272-
"""
273-
And the community-command/features/steps directory should contain:
274-
"""
275-
given.php
276-
then.php
277-
when.php
278-
"""
279-
And the community-command/features/extra directory should contain:
280-
"""
281-
no-mail.php
282-
"""
283-
284-
When I run `wp eval "if ( is_executable( 'community-command/bin/install-package-tests.sh' ) ) { echo 'executable'; } else { exit( 1 ); }"`
285-
Then STDOUT should be:
286-
"""
287-
executable
288-
"""
289-
290-
When I try `wp scaffold package-tests invalid-command`
291-
Then STDERR should be:
292-
"""
293-
Error: Invalid package directory. composer.json file must be present.
294-
"""
295-
296222
Scenario: Scaffold starter code for a theme
297223
Given a WP install
298224
Given I run `wp theme path`

php/commands/scaffold.php

Lines changed: 0 additions & 105 deletions
Original file line numberDiff line numberDiff line change
@@ -370,111 +370,6 @@ private function get_output_path( $assoc_args, $subdir ) {
370370
return $path;
371371
}
372372

373-
/**
374-
* Generate files needed for writing Behat tests for your command.
375-
*
376-
* ## DESCRIPTION
377-
*
378-
* These are the files that are generated:
379-
*
380-
* * `.travis.yml` is the configuration file for Travis CI
381-
* * `bin/install-package-tests.sh` will configure environment to run tests. Script expects WP_CLI_BIN_DIR and WP_CLI_CONFIG_PATH environment variables.
382-
* * `features/load-wp-cli.feature` is a basic test to confirm WP-CLI can load.
383-
* * `features/bootstrap`, `features/steps`, `features/extra` are Behat configuration files.
384-
* * `utils/generate-package-require-from-composer.php` generates a test config.yml file from your package's composer.json
385-
*
386-
* ## ENVIRONMENT
387-
*
388-
* The `features/bootstrap/FeatureContext.php` file expects the WP_CLI_BIN_DIR and WP_CLI_CONFIG_PATH environment variables.
389-
*
390-
* WP-CLI Behat framework uses Behat ~2.5.
391-
*
392-
* ## OPTIONS
393-
*
394-
* <dir>
395-
* : The package directory to generate tests for.
396-
*
397-
* [--force]
398-
* : Overwrite files that already exist.
399-
*
400-
* ## EXAMPLE
401-
*
402-
* wp scaffold package-tests /path/to/command/dir/
403-
*
404-
* @when before_wp_load
405-
* @subcommand package-tests
406-
*/
407-
public function package_tests( $args, $assoc_args ) {
408-
409-
list( $package_dir ) = $args;
410-
411-
if ( is_file( $package_dir ) ) {
412-
$package_dir = dirname( $package_dir );
413-
} else if ( is_dir( $package_dir ) ) {
414-
$package_dir = rtrim( $package_dir, '/' );
415-
}
416-
417-
if ( ! is_dir( $package_dir ) || ! file_exists( $package_dir . '/composer.json' ) ) {
418-
WP_CLI::error( "Invalid package directory. composer.json file must be present." );
419-
}
420-
421-
$package_dir .= '/';
422-
$bin_dir = $package_dir . 'bin/';
423-
$utils_dir = $package_dir . 'utils/';
424-
$features_dir = $package_dir . 'features/';
425-
$bootstrap_dir = $features_dir . 'bootstrap/';
426-
$steps_dir = $features_dir . 'steps/';
427-
$extra_dir = $features_dir . 'extra/';
428-
foreach ( array( $features_dir, $bootstrap_dir, $steps_dir, $extra_dir, $utils_dir, $bin_dir ) as $dir ) {
429-
if ( ! is_dir( $dir ) ) {
430-
Process::create( Utils\esc_cmd( 'mkdir %s', $dir ) )->run();
431-
}
432-
}
433-
434-
$to_copy = array(
435-
'templates/.travis.package.yml' => $package_dir,
436-
'templates/load-wp-cli.feature' => $features_dir,
437-
'templates/install-package-tests.sh' => $bin_dir,
438-
'features/bootstrap/FeatureContext.php' => $bootstrap_dir,
439-
'features/bootstrap/support.php' => $bootstrap_dir,
440-
'php/WP_CLI/Process.php' => $bootstrap_dir,
441-
'php/utils.php' => $bootstrap_dir,
442-
'ci/behat-tags.php' => $utils_dir,
443-
'utils/get-package-require-from-composer.php' => $utils_dir,
444-
'features/steps/given.php' => $steps_dir,
445-
'features/steps/when.php' => $steps_dir,
446-
'features/steps/then.php' => $steps_dir,
447-
'features/extra/no-mail.php' => $extra_dir,
448-
);
449-
450-
$files_written = array();
451-
foreach ( $to_copy as $file => $dir ) {
452-
// file_get_contents() works with Phar-archived files
453-
$contents = file_get_contents( WP_CLI_ROOT . "/{$file}" );
454-
$file_path = $dir . basename( $file );
455-
$file_path = str_replace( array( '.travis.package.yml' ), array( '.travis.yml' ), $file_path );
456-
457-
$force = \WP_CLI\Utils\get_flag_value( $assoc_args, 'force' );
458-
$should_write_file = $this->prompt_if_files_will_be_overwritten( $file_path, $force );
459-
if ( ! $should_write_file ) {
460-
continue;
461-
}
462-
$files_written[] = $file_path;
463-
464-
$result = Process::create( Utils\esc_cmd( 'touch %s', $file_path ) )->run();
465-
file_put_contents( $file_path, $contents );
466-
if ( 'templates/install-package-tests.sh' === $file ) {
467-
Process::create( Utils\esc_cmd( 'chmod +x %s', $file_path ) )->run();
468-
}
469-
}
470-
$this->log_whether_files_written(
471-
$files_written,
472-
$skip_message = 'All package tests were skipped.',
473-
$success_message = 'Created test files.'
474-
);
475-
476-
}
477-
478373
/**
479374
* Generate starter code for a plugin.
480375
*

templates/.travis.package.yml

Lines changed: 0 additions & 24 deletions
This file was deleted.

templates/install-package-tests.sh

Lines changed: 0 additions & 54 deletions
This file was deleted.

templates/load-wp-cli.feature

Lines changed: 0 additions & 10 deletions
This file was deleted.

utils/make-phar.php

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -101,7 +101,6 @@ function set_file_contents( $phar, $path, $content ) {
101101
add_file( $phar, WP_CLI_ROOT . '/ci/behat-tags.php' );
102102
add_file( $phar, WP_CLI_ROOT . '/vendor/composer/composer/LICENSE' );
103103
add_file( $phar, WP_CLI_ROOT . '/vendor/composer/composer/res/composer-schema.json' );
104-
add_file( $phar, WP_CLI_ROOT . '/utils/get-package-require-from-composer.php' );
105104
add_file( $phar, WP_CLI_ROOT . '/vendor/rmccue/requests/library/Requests/Transport/cacert.pem' );
106105

107106
set_file_contents( $phar, WP_CLI_ROOT . '/VERSION', $current_version );

0 commit comments

Comments
 (0)