aboutsummaryrefslogtreecommitdiffhomepage
path: root/crates/shirabe/tests/plugin/fixtures/e2e-command
diff options
context:
space:
mode:
authornsfisis <nsfisis@gmail.com>2026-08-05 03:58:11 +0900
committernsfisis <nsfisis@gmail.com>2026-08-05 03:58:11 +0900
commit3b0787fdecc21edf9ad22b82f547363c1aa79b15 (patch)
tree0dfa0d7b8e108c14a13dd468d43852682ec39b8c /crates/shirabe/tests/plugin/fixtures/e2e-command
parent9b444a9a879b75a6af3d3c7ba8b9a4294574c3ec (diff)
downloadphp-shirabe-3b0787fdecc21edf9ad22b82f547363c1aa79b15.tar.gz
php-shirabe-3b0787fdecc21edf9ad22b82f547363c1aa79b15.tar.zst
php-shirabe-3b0787fdecc21edf9ad22b82f547363c1aa79b15.zip
test(plugin): compare plugin-provided command execution against upstream
A Shirabe-authored CommandProvider fixture plugin (greet) runs under both implementations: exit codes, the command's own output, help/list rendering, alias resolution, a validation failure, and a file recording the shared object graph the command observed (root package, strict application FQCN, and the exit code of the built-in about command it invoked) must match. Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
Diffstat (limited to 'crates/shirabe/tests/plugin/fixtures/e2e-command')
-rw-r--r--crates/shirabe/tests/plugin/fixtures/e2e-command/plugin/composer.json17
-rw-r--r--crates/shirabe/tests/plugin/fixtures/e2e-command/plugin/src/GreetCommand.php48
-rw-r--r--crates/shirabe/tests/plugin/fixtures/e2e-command/plugin/src/GreetCommandProvider.php13
-rw-r--r--crates/shirabe/tests/plugin/fixtures/e2e-command/plugin/src/Plugin.php30
-rw-r--r--crates/shirabe/tests/plugin/fixtures/e2e-command/project/composer.json24
5 files changed, 132 insertions, 0 deletions
diff --git a/crates/shirabe/tests/plugin/fixtures/e2e-command/plugin/composer.json b/crates/shirabe/tests/plugin/fixtures/e2e-command/plugin/composer.json
new file mode 100644
index 00000000..76cf19e9
--- /dev/null
+++ b/crates/shirabe/tests/plugin/fixtures/e2e-command/plugin/composer.json
@@ -0,0 +1,17 @@
+{
+ "name": "shirabe-test/command-provider",
+ "version": "1.0.0",
+ "type": "composer-plugin",
+ "description": "Fixture plugin providing a command through the CommandProvider capability.",
+ "autoload": {
+ "psr-4": {
+ "ShirabeTest\\CommandProvider\\": "src/"
+ }
+ },
+ "require": {
+ "composer-plugin-api": "^2.0"
+ },
+ "extra": {
+ "class": "ShirabeTest\\CommandProvider\\Plugin"
+ }
+}
diff --git a/crates/shirabe/tests/plugin/fixtures/e2e-command/plugin/src/GreetCommand.php b/crates/shirabe/tests/plugin/fixtures/e2e-command/plugin/src/GreetCommand.php
new file mode 100644
index 00000000..51b3e765
--- /dev/null
+++ b/crates/shirabe/tests/plugin/fixtures/e2e-command/plugin/src/GreetCommand.php
@@ -0,0 +1,48 @@
+<?php
+
+namespace ShirabeTest\CommandProvider;
+
+use Composer\Command\BaseCommand;
+use Symfony\Component\Console\Input\ArrayInput;
+use Symfony\Component\Console\Input\InputArgument;
+use Symfony\Component\Console\Input\InputInterface;
+use Symfony\Component\Console\Input\InputOption;
+use Symfony\Component\Console\Output\OutputInterface;
+
+class GreetCommand extends BaseCommand
+{
+ protected function configure(): void
+ {
+ $this
+ ->setName('greet')
+ ->setAliases(['hi'])
+ ->setDescription('Greets someone from a plugin-provided command.')
+ ->setHelp('The <info>greet</info> command exercises plugin-provided command execution.')
+ ->addArgument('who', InputArgument::REQUIRED, 'Who to greet')
+ ->addOption('shout', 's', InputOption::VALUE_NONE, 'Uppercase the greeting')
+ ->addOption('out', null, InputOption::VALUE_REQUIRED, 'File the command writes its observations to');
+ }
+
+ protected function execute(InputInterface $input, OutputInterface $output): int
+ {
+ $message = 'Hello ' . $input->getArgument('who');
+ if ($input->getOption('shout')) {
+ $message = strtoupper($message);
+ }
+ $this->getIO()->write('greet: ' . $message);
+
+ $composer = $this->requireComposer();
+ $lines = [
+ 'root=' . $composer->getPackage()->getName(),
+ 'app=' . get_class($this->getApplication()),
+ ];
+ $aboutExit = $this->getApplication()->find('about')->run(new ArrayInput(['command' => 'about']), $output);
+ $lines[] = 'about=' . $aboutExit;
+ $out = $input->getOption('out');
+ if ($out !== null) {
+ file_put_contents($out, implode("\n", $lines) . "\n");
+ }
+
+ return 0;
+ }
+}
diff --git a/crates/shirabe/tests/plugin/fixtures/e2e-command/plugin/src/GreetCommandProvider.php b/crates/shirabe/tests/plugin/fixtures/e2e-command/plugin/src/GreetCommandProvider.php
new file mode 100644
index 00000000..ce36e062
--- /dev/null
+++ b/crates/shirabe/tests/plugin/fixtures/e2e-command/plugin/src/GreetCommandProvider.php
@@ -0,0 +1,13 @@
+<?php
+
+namespace ShirabeTest\CommandProvider;
+
+use Composer\Plugin\Capability\CommandProvider as CommandProviderCapability;
+
+class GreetCommandProvider implements CommandProviderCapability
+{
+ public function getCommands(): array
+ {
+ return [new GreetCommand()];
+ }
+}
diff --git a/crates/shirabe/tests/plugin/fixtures/e2e-command/plugin/src/Plugin.php b/crates/shirabe/tests/plugin/fixtures/e2e-command/plugin/src/Plugin.php
new file mode 100644
index 00000000..fc708b1f
--- /dev/null
+++ b/crates/shirabe/tests/plugin/fixtures/e2e-command/plugin/src/Plugin.php
@@ -0,0 +1,30 @@
+<?php
+
+namespace ShirabeTest\CommandProvider;
+
+use Composer\Composer;
+use Composer\IO\IOInterface;
+use Composer\Plugin\Capable;
+use Composer\Plugin\PluginInterface;
+
+class Plugin implements PluginInterface, Capable
+{
+ public function activate(Composer $composer, IOInterface $io): void
+ {
+ }
+
+ public function deactivate(Composer $composer, IOInterface $io): void
+ {
+ }
+
+ public function uninstall(Composer $composer, IOInterface $io): void
+ {
+ }
+
+ public function getCapabilities(): array
+ {
+ return [
+ 'Composer\Plugin\Capability\CommandProvider' => GreetCommandProvider::class,
+ ];
+ }
+}
diff --git a/crates/shirabe/tests/plugin/fixtures/e2e-command/project/composer.json b/crates/shirabe/tests/plugin/fixtures/e2e-command/project/composer.json
new file mode 100644
index 00000000..e68a53de
--- /dev/null
+++ b/crates/shirabe/tests/plugin/fixtures/e2e-command/project/composer.json
@@ -0,0 +1,24 @@
+{
+ "name": "shirabe/e2e-command-provider",
+ "description": "E2E fixture project: run a plugin-provided command against upstream Composer and Shirabe.",
+ "repositories": [
+ {
+ "type": "path",
+ "url": "../plugin",
+ "options": {
+ "symlink": false
+ }
+ },
+ {
+ "packagist.org": false
+ }
+ ],
+ "require": {
+ "shirabe-test/command-provider": "1.0.0"
+ },
+ "config": {
+ "allow-plugins": {
+ "shirabe-test/command-provider": true
+ }
+ }
+}