@@ -1017,6 +1017,98 @@ Feature: Install WP-CLI packages
10171017 wp-cli/google-sitemap-generator-cli
10181018 """
10191019
1020+ Scenario: Install a package from a remote zip URL
1021+ Given an empty directory
1022+ And a remote-zip-test-command/composer.json file:
1023+ """
1024+ {
1025+ "name" : "wp-cli-test/remote-zip-test-command" ,
1026+ "description" : "Dummy package served over HTTP as a ZIP archive for acceptance tests." ,
1027+ "type" : "wp-cli-package"
1028+ }
1029+ """
1030+ And I run `php -r '$zip = new ZipArchive(); $zip->open( "remote-zip-test-command.zip", ZipArchive::CREATE | ZipArchive::OVERWRITE ); $zip->addFromString( "remote-zip-test-command/composer.json", file_get_contents( "remote-zip-test-command/composer.json" ) ); $zip->close();'`
1031+ And a PHP built-in web server
1032+
1033+ When I run `wp package install http://localhost:8080/remote-zip-test-command.zip`
1034+ Then STDOUT should contain:
1035+ """
1036+ Installing package wp-cli-test/remote-zip-test-command
1037+ """
1038+ And STDOUT should contain:
1039+ """
1040+ Success: Package installed.
1041+ """
1042+
1043+ When I run `wp package is-installed wp-cli-test/remote-zip-test-command`
1044+ Then the return code should be 0
1045+ And STDERR should be empty
1046+ And STDOUT should be empty
1047+
1048+ Scenario: Install a package from a remote zip URL with files at archive root
1049+ Given an empty directory
1050+ And a composer-flat.json file:
1051+ """
1052+ {
1053+ "name" : "wp-cli-test/remote-zip-flat-command" ,
1054+ "description" : "Dummy flat-layout ZIP package for acceptance tests." ,
1055+ "type" : "wp-cli-package"
1056+ }
1057+ """
1058+ And I run `php -r '$zip = new ZipArchive(); $zip->open( "remote-zip-flat-command.zip", ZipArchive::CREATE | ZipArchive::OVERWRITE ); $zip->addFromString( "composer.json", file_get_contents( "composer-flat.json" ) ); $zip->close();'`
1059+ And a PHP built-in web server
1060+
1061+ When I run `wp package install http://localhost:8080/remote-zip-flat-command.zip`
1062+ Then STDOUT should contain:
1063+ """
1064+ Installing package wp-cli-test/remote-zip-flat-command
1065+ """
1066+ And STDOUT should contain:
1067+ """
1068+ Success: Package installed.
1069+ """
1070+
1071+ When I run `wp package is-installed wp-cli-test/remote-zip-flat-command`
1072+ Then the return code should be 0
1073+ And STDERR should be empty
1074+ And STDOUT should be empty
1075+
1076+ Scenario: Install from a remote zip URL with invalid zip contents
1077+ Given an empty directory
1078+ And an invalid.zip file:
1079+ """
1080+ this is not a zip archive
1081+ """
1082+ And a PHP built-in web server
1083+
1084+ When I try `wp package install http://localhost:8080/invalid.zip`
1085+ Then the return code should be 1
1086+ And STDERR should contain:
1087+ """
1088+ ZipArchive failed to unzip
1089+ """
1090+
1091+ Scenario: Install from a remote zip URL that returns 404
1092+ Given an empty directory
1093+ And a PHP built-in web server
1094+
1095+ When I try `wp package install http://localhost:8080/missing.zip`
1096+ Then the return code should be 1
1097+ And STDERR should contain:
1098+ """
1099+ Couldn't download package from 'http://localhost:8080/missing.zip' (HTTP code 404).
1100+ """
1101+
1102+ Scenario: Install from a remote zip URL that cannot be reached
1103+ Given an empty directory
1104+
1105+ When I try `wp package install http://localhost:1/unreachable.zip`
1106+ Then the return code should be 1
1107+ And STDERR should contain:
1108+ """
1109+ Error: Failed to get url 'http://localhost:1/unreachable.zip'
1110+ """
1111+
10201112 @github-api
10211113 Scenario: Install a package from Git using a shortened mixed-case package identifier but lowercase composer.json name
10221114 Given an empty directory
0 commit comments