|
| 1 | +Feature: Install WP-CLI packages |
| 2 | + |
| 3 | + Background: |
| 4 | + When I run `wp package path` |
| 5 | + Then save STDOUT as {PACKAGE_PATH} |
| 6 | + |
| 7 | + Scenario: Install a package requiring a WP-CLI version that doesn't match |
| 8 | + Given an empty directory |
| 9 | + And a new Phar with version "0.23.0" |
| 10 | + And a path-command/command.php file: |
| 11 | + """ |
| 12 | + <?php |
| 13 | + WP_CLI::add_command( 'community-command', function(){ |
| 14 | + WP_CLI::success( "success!" ); |
| 15 | + }, array( 'when' => 'before_wp_load' ) ); |
| 16 | + """ |
| 17 | + And a path-command/composer.json file: |
| 18 | + """ |
| 19 | + { |
| 20 | + "name": "wp-cli/community-command", |
| 21 | + "description": "A demo community command.", |
| 22 | + "license": "MIT", |
| 23 | + "minimum-stability": "dev", |
| 24 | + "autoload": { |
| 25 | + "files": [ "command.php" ] |
| 26 | + }, |
| 27 | + "require": { |
| 28 | + "wp-cli/wp-cli": ">=0.24.0" |
| 29 | + }, |
| 30 | + "require-dev": { |
| 31 | + "behat/behat": "~2.5" |
| 32 | + } |
| 33 | + } |
| 34 | + """ |
| 35 | + |
| 36 | + When I try `{PHAR_PATH} package install path-command` |
| 37 | + Then STDOUT should contain: |
| 38 | + """ |
| 39 | + wp-cli/community-command dev-master requires wp-cli/wp-cli >=0.24.0 |
| 40 | + """ |
| 41 | + And STDERR should contain: |
| 42 | + """ |
| 43 | + Error: Package installation failed |
| 44 | + """ |
| 45 | + And the return code should be 1 |
| 46 | + |
| 47 | + When I run `cat {PACKAGE_PATH}composer.json` |
| 48 | + Then STDOUT should contain: |
| 49 | + """ |
| 50 | + "version": "0.23.0", |
| 51 | + """ |
| 52 | + |
| 53 | + Scenario: Install a package requiring a WP-CLI version that does match |
| 54 | + Given an empty directory |
| 55 | + And a new Phar with version "0.23.0" |
| 56 | + And a path-command/command.php file: |
| 57 | + """ |
| 58 | + <?php |
| 59 | + WP_CLI::add_command( 'community-command', function(){ |
| 60 | + WP_CLI::success( "success!" ); |
| 61 | + }, array( 'when' => 'before_wp_load' ) ); |
| 62 | + """ |
| 63 | + And a path-command/composer.json file: |
| 64 | + """ |
| 65 | + { |
| 66 | + "name": "wp-cli/community-command", |
| 67 | + "description": "A demo community command.", |
| 68 | + "license": "MIT", |
| 69 | + "minimum-stability": "dev", |
| 70 | + "autoload": { |
| 71 | + "files": [ "command.php" ] |
| 72 | + }, |
| 73 | + "require": { |
| 74 | + "wp-cli/wp-cli": ">=0.22.0" |
| 75 | + }, |
| 76 | + "require-dev": { |
| 77 | + "behat/behat": "~2.5" |
| 78 | + } |
| 79 | + } |
| 80 | + """ |
| 81 | + |
| 82 | + # Allow for composer/ca-bundle using `openssl_x509_parse()` which throws PHP warnings on old versions of PHP. |
| 83 | + When I try `{PHAR_PATH} package install path-command` |
| 84 | + Then STDOUT should contain: |
| 85 | + """ |
| 86 | + Success: Package installed. |
| 87 | + """ |
| 88 | + And the return code should be 0 |
| 89 | + |
| 90 | + When I run `cat {PACKAGE_PATH}composer.json` |
| 91 | + Then STDOUT should contain: |
| 92 | + """ |
| 93 | + "version": "0.23.0", |
| 94 | + """ |
| 95 | + |
| 96 | + Scenario: Install a package requiring a WP-CLI alpha version that does match |
| 97 | + Given an empty directory |
| 98 | + And a new Phar with version "0.23.0-alpha-90ecad6" |
| 99 | + And a path-command/command.php file: |
| 100 | + """ |
| 101 | + <?php |
| 102 | + WP_CLI::add_command( 'community-command', function(){ |
| 103 | + WP_CLI::success( "success!" ); |
| 104 | + }, array( 'when' => 'before_wp_load' ) ); |
| 105 | + """ |
| 106 | + And a path-command/composer.json file: |
| 107 | + """ |
| 108 | + { |
| 109 | + "name": "wp-cli/community-command", |
| 110 | + "description": "A demo community command.", |
| 111 | + "license": "MIT", |
| 112 | + "minimum-stability": "dev", |
| 113 | + "autoload": { |
| 114 | + "files": [ "command.php" ] |
| 115 | + }, |
| 116 | + "require": { |
| 117 | + "wp-cli/wp-cli": ">=0.22.0" |
| 118 | + }, |
| 119 | + "require-dev": { |
| 120 | + "behat/behat": "~2.5" |
| 121 | + } |
| 122 | + } |
| 123 | + """ |
| 124 | + |
| 125 | + # Allow for composer/ca-bundle using `openssl_x509_parse()` which throws PHP warnings on old versions of PHP. |
| 126 | + When I try `{PHAR_PATH} package install path-command` |
| 127 | + Then STDOUT should contain: |
| 128 | + """ |
| 129 | + Success: Package installed. |
| 130 | + """ |
| 131 | + And the return code should be 0 |
| 132 | + |
| 133 | + When I run `cat {PACKAGE_PATH}composer.json` |
| 134 | + Then STDOUT should contain: |
| 135 | + """ |
| 136 | + "version": "0.23.0-alpha", |
| 137 | + """ |
0 commit comments